Skip to content

Commit d99adb7

Browse files
cypharsmb49
authored andcommitted
openat2: explicitly return -E2BIG for (usize > PAGE_SIZE)
BugLink: https://bugs.launchpad.net/bugs/2097575 commit f92f0a1 upstream. 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: fddb5d4 ("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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Manuel Diewald <manuel.diewald@canonical.com> Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
1 parent c257731 commit d99adb7

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

fs/open.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1446,6 +1446,8 @@ SYSCALL_DEFINE4(openat2, int, dfd, const char __user *, filename,
14461446

14471447
if (unlikely(usize < OPEN_HOW_SIZE_VER0))
14481448
return -EINVAL;
1449+
if (unlikely(usize > PAGE_SIZE))
1450+
return -E2BIG;
14491451

14501452
err = copy_struct_from_user(&tmp, sizeof(tmp), how, usize);
14511453
if (err)

0 commit comments

Comments
 (0)