summaryrefslogtreecommitdiff
path: root/mm
diff options
context:
space:
mode:
authorRoberto Sassu <roberto.sassu@huawei.com>2023-06-07 15:24:27 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-06-28 10:28:09 +0200
commit051d6421337b473803bf6ae50ae05be1f0db64fb (patch)
treefb2992c787cd597841019a5adcb2c6c271c6b8ca /mm
parent1ac6e9ee842859f03dc9e29ebfd50de478280ab6 (diff)
downloadlinux-051d6421337b473803bf6ae50ae05be1f0db64fb.tar.gz
linux-051d6421337b473803bf6ae50ae05be1f0db64fb.tar.bz2
linux-051d6421337b473803bf6ae50ae05be1f0db64fb.zip
memfd: check for non-NULL file_seals in memfd_create() syscall
[ Upstream commit 935d44acf621aa0688fef8312dec3e5940f38f4e ] 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. Link: https://lkml.kernel.org/r/20230607132427.2867435-1-roberto.sassu@huaweicloud.com Fixes: 47b9012ecdc7 ("shmem: add sealing support to hugetlb-backed memfd") Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com> Cc: Marc-Andr Lureau <marcandre.lureau@redhat.com> Cc: Mike Kravetz <mike.kravetz@oracle.com> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/memfd.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/mm/memfd.c b/mm/memfd.c
index fae4142f7d25..278e5636623e 100644
--- a/mm/memfd.c
+++ b/mm/memfd.c
@@ -330,7 +330,8 @@ SYSCALL_DEFINE2(memfd_create,
if (flags & MFD_ALLOW_SEALING) {
file_seals = memfd_file_seals_ptr(file);
- *file_seals &= ~F_SEAL_SEAL;
+ if (file_seals)
+ *file_seals &= ~F_SEAL_SEAL;
}
fd_install(fd, file);