[PATCH 0/2] mm/userfaultfd: Fix uninitialized output field for -EAGAIN race

From: Peter Xu
Date: Thu Apr 24 2025 - 17:57:43 EST


When discussing some userfaultfd issues with Andrea, Andrea pointed out an
ABI issue with userfaultfd that existed for years. Luckily the issue
should only be a very corner case one, and the fix (even if changing the
kernel ABI) should only be in the good way, IOW there should have no risk
breaking any userapp but only fixing.

This issue also should not matter if the userapp didn't enable any of the
UFFD_FEATURE_EVENT_* feature.

The first patch contains more information on the issue and the fix. The
2nd patch is a test case I added which would fail on old kernels (including
current latest branches) but will start working after patch 1 applied.

Thanks,

Peter Xu (2):
mm/userfaultfd: Fix uninitialized output field for -EAGAIN race
mm/selftests: Add a test to verify mmap_changing race with -EAGAIN

fs/userfaultfd.c | 28 ++-
tools/testing/selftests/mm/uffd-unit-tests.c | 203 +++++++++++++++++++
2 files changed, 225 insertions(+), 6 deletions(-)

--
2.48.1