summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorAleksa Sarai <cyphar@cyphar.com>2024-10-09 23:40:36 +0300
committerChristian Brauner <brauner@kernel.org>2024-10-10 13:09:03 +0300
commitf92f0a1b05698340836229d791b3ffecc71b265a (patch)
treea57b2aea69ecc14183643d65892741dc35739ea1 /fs
parent368196e5019464c7bf81c797a415d09e53f5792a (diff)
downloadlinux-f92f0a1b05698340836229d791b3ffecc71b265a.tar.xz
openat2: explicitly return -E2BIG for (usize > PAGE_SIZE)
While we do currently return -EFAULT in this case, it seems prudent to follow the behaviour of other syscalls like clone3. It seems quite unlikely that anyone depends on this error code being EFAULT, but we can always revert this if it turns out to be an issue. Cc: stable@vger.kernel.org # v5.6+ Fixes: fddb5d430ad9 ("open: introduce openat2(2) syscall") Signed-off-by: Aleksa Sarai <cyphar@cyphar.com> Link: https://lore.kernel.org/r/20241010-extensible-structs-check_fields-v3-3-d2833dfe6edd@cyphar.com Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/open.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/open.c b/fs/open.c
index acaeb3e25c88..5da4df2f9b18 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -1457,6 +1457,8 @@ SYSCALL_DEFINE4(openat2, int, dfd, const char __user *, filename,
if (unlikely(usize < OPEN_HOW_SIZE_VER0))
return -EINVAL;
+ if (unlikely(usize > PAGE_SIZE))
+ return -E2BIG;
err = copy_struct_from_user(&tmp, sizeof(tmp), how, usize);
if (err)