]> git.ipfire.org Git - thirdparty/linux.git/commit
mm/selftests: add a test to verify mmap_changing race with -EAGAIN
authorPeter Xu <peterx@redhat.com>
Thu, 24 Apr 2025 21:57:29 +0000 (17:57 -0400)
committerAndrew Morton <akpm@linux-foundation.org>
Tue, 13 May 2025 06:50:45 +0000 (23:50 -0700)
commitf60b6634cd88a749fdcd9edfeb2079c23aa05b66
treed2fe40a7d11a6b972c33292fccdfa5889e392c79
parent4428a35f91f0f0e31d874038b3091e1c5a461f34
mm/selftests: add a test to verify mmap_changing race with -EAGAIN

Add an unit test to verify the recent mmap_changing ABI breakage.

Note that I used some tricks here and there to make the test simple, e.g.
I abused UFFDIO_MOVE on top of shmem with the fact that I know what I want
to test will be even earlier than the vma type check.  Rich comments were
added to explain trivial details.

Before that fix, -EAGAIN would have been written to the copy field most of
the time but not always; the test should be able to reliably trigger the
outlier case.  After the fix, it's written always, the test verifies that
making sure corresponding field (e.g.  copy.copy for UFFDIO_COPY) is
updated.

[akpm@linux-foundation.org: coding-style cleanups]
Link: https://lkml.kernel.org/r/20250424215729.194656-3-peterx@redhat.com
Signed-off-by: Peter Xu <peterx@redhat.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Axel Rasmussen <axelrasmussen@google.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
tools/testing/selftests/mm/uffd-unit-tests.c