]> www.infradead.org Git - users/jedix/linux-maple.git/commit
selftests/proc: add /proc/pid/maps tearing from vma split test
authorSuren Baghdasaryan <surenb@google.com>
Fri, 4 Jul 2025 06:07:19 +0000 (23:07 -0700)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Wed, 9 Jul 2025 15:10:29 +0000 (11:10 -0400)
commit1747022146d23d08aa1e50dc2199d930afec5792
tree86926c1ce28e3eaf44564d280d93f3e2b8598f17
parentd7b8f8e20813f0179d8ef519541a3527e7661d3a
selftests/proc: add /proc/pid/maps tearing from vma split test

The /proc/pid/maps file is generated page by page, with the mmap_lock
released between pages.  This can lead to inconsistent reads if the
underlying vmas are concurrently modified. For instance, if a vma split
or merge occurs at a page boundary while /proc/pid/maps is being read,
the same vma might be seen twice: once before and once after the change.
This duplication is considered acceptable for userspace handling.
However, observing a "hole" where a vma should be (e.g., due to a vma
being replaced and the space temporarily being empty) is unacceptable.

Implement a test that:
1. Forks a child process which continuously modifies its address space,
specifically targeting a vma at the boundary between two pages.
2. The parent process repeatedly reads the child's /proc/pid/maps.
3. The parent process checks the last vma of the first page and
the first vma of the second page for consistency, looking for the
effects of vma splits or merges.

The test duration is configurable via the -d command-line parameter
in seconds to increase the likelihood of catching the race condition.
The default test duration is 5 seconds.

Example Command: proc-maps-race -d 10

Signed-off-by: Suren Baghdasaryan <surenb@google.com>
tools/testing/selftests/proc/.gitignore
tools/testing/selftests/proc/Makefile
tools/testing/selftests/proc/proc-maps-race.c [new file with mode: 0644]