]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
openat2: explicitly return -E2BIG for (usize > PAGE_SIZE)
authorAleksa Sarai <cyphar@cyphar.com>
Wed, 9 Oct 2024 20:40:36 +0000 (07:40 +1100)
committerChristian Brauner <brauner@kernel.org>
Thu, 10 Oct 2024 10:09:03 +0000 (12:09 +0200)
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>
fs/open.c

index acaeb3e25c88ecdd635619872eea8ebe23622349..5da4df2f9b18a637ed83cde8f2fe52f9034f5290 100644 (file)
--- 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)