FAILED: patch "[PATCH] memfd: check for non-NULL file_seals in memfd_create()" failed to apply to 6.1-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 6.1-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.1.y
git checkout FETCH_HEAD
git cherry-pick -x 935d44acf621aa0688fef8312dec3e5940f38f4e
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2023062314-saffron-portly-6c2a@gregkh' --subject-prefix 'PATCH 6.1.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 935d44acf621aa0688fef8312dec3e5940f38f4e Mon Sep 17 00:00:00 2001
From: Roberto Sassu <[email protected]>
Date: Wed, 7 Jun 2023 15:24:27 +0200
Subject: [PATCH] memfd: check for non-NULL file_seals in memfd_create()
syscall
Ensure that file_seals is non-NULL before using it in the memfd_create() syscall. One situation in which memfd_file_seals_ptr() could return a NULL pointer when CONFIG_SHMEM=n, oopsing the kernel.
mm/memfd.c +6 -3
@@ -371,12 +371,15 @@ SYSCALL_DEFINE2(memfd_create, inode->i_mode &= ~0111 ; file_seals =memfd_file_seals_ptr (file); - *file_seals &= ~F_SEAL_SEAL ; - *file_seals |=F_SEAL_EXEC ; +if (file_seals) { + *file_seals &= ~F_SEAL_SEAL ; + *file_seals |=F_SEAL_EXEC ; + } }else if (flags &MFD_ALLOW_SEALING ) {/* MFD_EXEC and MFD_ALLOW_SEALING are set */ file_seals =memfd_file_seals_ptr (file); - *file_seals &= ~F_SEAL_SEAL ; +if (file_seals) + *file_seals &= ~F_SEAL_SEAL ; }fd_install (fd, file);