diff options
| author | Hongfu Li <lihongfu@kylinos.cn> | 2026-07-17 15:02:51 +0800 |
|---|---|---|
| committer | Andrew Morton <akpm@linux-foundation.org> | 2026-08-06 18:57:14 -0700 |
| commit | 1605ce99afac80cd6080c821a664921c19eb3e00 (patch) | |
| tree | f9bb508c9b604761eb4305bb20900dbfb0722243 | |
| parent | 430e4cdcc6002db49814780e105b8e534b614fcc (diff) | |
| download | linux-stable-1605ce99afac80cd6080c821a664921c19eb3e00.tar.gz linux-stable-1605ce99afac80cd6080c821a664921c19eb3e00.zip | |
selftests/mm: fix BUG_ON checking wrong variable in mremap_dontunmap
In mremap_dontunmap_partial_mapping_overwrite(), mremap() stores its
returned remapped address into remapped_mapping, while the BUG_ON
incorrectly checks dest_mapping instead.
If mremap() fails, dest_mapping still holds a valid pointer obtained from
the prior mmap() call, making this BUG_ON never trigger at all. Correct
the check to validate the actual mremap() return value stored in
remapped_mapping.
Link: https://lore.kernel.org/20260717070251.73212-1-hongfu.li@linux.dev
Signed-off-by: Hongfu Li <lihongfu@kylinos.cn>
Reviewed-by: SJ Park <sj@kernel.org>
Cc: David Hildenbrand <david@kernel.org>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Lorenzo Stoakes <ljs@kernel.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vlastimil Babka <vbabka@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
| -rw-r--r-- | tools/testing/selftests/mm/mremap_dontunmap.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/testing/selftests/mm/mremap_dontunmap.c b/tools/testing/selftests/mm/mremap_dontunmap.c index a4f75d836733..96ba537facf7 100644 --- a/tools/testing/selftests/mm/mremap_dontunmap.c +++ b/tools/testing/selftests/mm/mremap_dontunmap.c @@ -313,7 +313,7 @@ static void mremap_dontunmap_partial_mapping_overwrite(void) mremap(source_mapping, 5 * page_size, 5 * page_size, MREMAP_DONTUNMAP | MREMAP_MAYMOVE | MREMAP_FIXED, dest_mapping); - BUG_ON(dest_mapping == MAP_FAILED, "mremap"); + BUG_ON(remapped_mapping == MAP_FAILED, "mremap"); BUG_ON(dest_mapping != remapped_mapping, "expected to remap to dest_mapping"); BUG_ON(check_region_contains_byte(source_mapping, 5 * page_size, 0) != |
