diff options
| author | Hongfu Li <lihongfu@kylinos.cn> | 2026-08-03 18:30:46 +0800 |
|---|---|---|
| committer | Andrew Morton <akpm@linux-foundation.org> | 2026-08-13 15:42:07 -0700 |
| commit | 8f1d96a16c6313afb58b1ccc1ea0e8df4bd6efd7 (patch) | |
| tree | 3c69dc4d2d57143e79382ed218181744f7867ae0 /scripts/objdiff | |
| parent | 809f455a75fdfebf8cf3fee5ec6275989b2acedf (diff) | |
| download | linux-8f1d96a16c6313afb58b1ccc1ea0e8df4bd6efd7.tar.gz linux-8f1d96a16c6313afb58b1ccc1ea0e8df4bd6efd7.zip | |
selftests/prctl: fix non-anonymous VMA mapping in set-anon-vma-name test
The test creates a non-anonymous VMA (ptr_not_anon) via mmap() with
MAP_PRIVATE but without MAP_ANONYMOUS, using fd=0 (stdin) as the file
descriptor. This always fails because fd=0 is not a regular file, and the
failure was hidden because ASSERT_NE() incorrectly checked for NULL
instead of MAP_FAILED.
Fix by using mkstemp() + ftruncate() to create a real temporary file, then
mapping it with MAP_PRIVATE to obtain a genuine file-backed VMA. Also fix
the mmap() error checks to use MAP_FAILED instead of NULL, and pass fd=-1
for the anonymous mapping for clarity. The temp file is unlinked
immediately so it does not persist on disk.
Link: https://lore.kernel.org/20260803103046.14324-1-hongfu.li@linux.dev
Signed-off-by: Hongfu Li <lihongfu@kylinos.cn>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Wei Yang <richard.weiyang@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'scripts/objdiff')
0 files changed, 0 insertions, 0 deletions
