Skip to content

Commit 2ff559f

Browse files
xzpeterakpm00
authored andcommitted
Revert "userfaultfd: don't fail on unrecognized features"
This is a proposal to revert commit 914eedc. I found this when writing a simple UFFDIO_API test to be the first unit test in this set. Two things breaks with the commit: - UFFDIO_API check was lost and missing. According to man page, the kernel should reject ioctl(UFFDIO_API) if uffdio_api.api != 0xaa. This check is needed if the api version will be extended in the future, or user app won't be able to identify which is a new kernel. - Feature flags checks were removed, which means UFFDIO_API with a feature that does not exist will also succeed. According to the man page, we should (and it makes sense) to reject ioctl(UFFDIO_API) if unknown features passed in. Link: https://lore.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Fixes: 914eedc ("userfaultfd: don't fail on unrecognized features") Signed-off-by: Peter Xu <[email protected]> Acked-by: David Hildenbrand <[email protected]> Cc: Axel Rasmussen <[email protected]> Cc: Dmitry Safonov <[email protected]> Cc: Mike Kravetz <[email protected]> Cc: Mike Rapoport (IBM) <[email protected]> Cc: Zach O'Keefe <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 1ba1199 commit 2ff559f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

fs/userfaultfd.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1955,8 +1955,10 @@ static int userfaultfd_api(struct userfaultfd_ctx *ctx,
19551955
ret = -EFAULT;
19561956
if (copy_from_user(&uffdio_api, buf, sizeof(uffdio_api)))
19571957
goto out;
1958-
/* Ignore unsupported features (userspace built against newer kernel) */
1959-
features = uffdio_api.features & UFFD_API_FEATURES;
1958+
features = uffdio_api.features;
1959+
ret = -EINVAL;
1960+
if (uffdio_api.api != UFFD_API || (features & ~UFFD_API_FEATURES))
1961+
goto err_out;
19601962
ret = -EPERM;
19611963
if ((features & UFFD_FEATURE_EVENT_FORK) && !capable(CAP_SYS_PTRACE))
19621964
goto err_out;

0 commit comments

Comments
 (0)