The quilt patch titled Subject: Revert "userfaultfd: don't fail on unrecognized features" has been removed from the -mm tree. Its filename was revert-userfaultfd-dont-fail-on-unrecognized-features.patch This patch was dropped because it was merged into the mm-hotfixes-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm ------------------------------------------------------ From: Peter Xu <peterx@xxxxxxxxxx> Subject: Revert "userfaultfd: don't fail on unrecognized features" Date: Wed, 12 Apr 2023 12:38:52 -0400 This is a proposal to revert commit 914eedcb9ba0ff53c33808. 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/20220722201513.1624158-1-axelrasmussen@xxxxxxxxxx Link: https://lkml.kernel.org/r/20230412163922.327282-2-peterx@xxxxxxxxxx Fixes: 914eedcb9ba0 ("userfaultfd: don't fail on unrecognized features") Signed-off-by: Peter Xu <peterx@xxxxxxxxxx> Acked-by: David Hildenbrand <david@xxxxxxxxxx> Cc: Axel Rasmussen <axelrasmussen@xxxxxxxxxx> Cc: Dmitry Safonov <0x7f454c46@xxxxxxxxx> Cc: Mike Kravetz <mike.kravetz@xxxxxxxxxx> Cc: Mike Rapoport (IBM) <rppt@xxxxxxxxxx> Cc: Zach O'Keefe <zokeefe@xxxxxxxxxx> Cc: <stable@xxxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- fs/userfaultfd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/fs/userfaultfd.c~revert-userfaultfd-dont-fail-on-unrecognized-features +++ a/fs/userfaultfd.c @@ -1955,8 +1955,10 @@ static int userfaultfd_api(struct userfa ret = -EFAULT; if (copy_from_user(&uffdio_api, buf, sizeof(uffdio_api))) goto out; - /* Ignore unsupported features (userspace built against newer kernel) */ - features = uffdio_api.features & UFFD_API_FEATURES; + features = uffdio_api.features; + ret = -EINVAL; + if (uffdio_api.api != UFFD_API || (features & ~UFFD_API_FEATURES)) + goto err_out; ret = -EPERM; if ((features & UFFD_FEATURE_EVENT_FORK) && !capable(CAP_SYS_PTRACE)) goto err_out; _ Patches currently in -mm which might be from peterx@xxxxxxxxxx are selftests-mm-update-gitignore-with-two-missing-tests.patch selftests-mm-dump-a-summary-in-run_vmtestssh.patch selftests-mm-merge-utilh-into-vm_utilh.patch selftests-mm-use-test_gen_progs-where-proper.patch selftests-mm-link-vm_utilc-always.patch selftests-mm-merge-default_huge_page_size-into-one.patch selftests-mm-use-pm_-macros-in-vm_utilsh.patch selftests-mm-reuse-pagemap_get_entry-in-vm_utilh.patch selftests-mm-test-uffdio_zeropage-only-when-hugetlb.patch selftests-mm-drop-test_uffdio_zeropage_eexist.patch selftests-mm-create-uffd-common.patch selftests-mm-split-uffd-tests-into-uffd-stress-and-uffd-unit-tests.patch selftests-mm-uffd_register.patch selftests-mm-uffd_open_devsys.patch selftests-mm-uffdio_api-test.patch selftests-mm-drop-global-mem_fd-in-uffd-tests.patch selftests-mm-drop-global-hpage_size-in-uffd-tests.patch selftests-mm-rename-uffd_stats-to-uffd_args.patch selftests-mm-let-uffd_handle_page_fault-take-wp-parameter.patch selftests-mm-allow-allocate_area-to-fail-properly.patch selftests-mm-add-framework-for-uffd-unit-test.patch selftests-mm-move-uffd-pagemap-test-to-unit-test.patch selftests-mm-move-uffd-minor-test-to-unit-test.patch selftests-mm-move-uffd-sig-events-tests-into-uffd-unit-tests.patch selftests-mm-move-zeropage-test-into-uffd-unit-tests.patch selftests-mm-workaround-no-way-to-detect-uffd-minor-wp.patch selftests-mm-allow-uffd-test-to-skip-properly-with-no-privilege.patch selftests-mm-drop-sys-dev-test-in-uffd-stress-test.patch selftests-mm-add-shmem-private-test-to-uffd-stress.patch selftests-mm-add-uffdio-register-ioctls-test.patch