* + selftests-mm-mremap_test-validate-the-preamble-region-before-mapping-it.patch added to mm-unstable branch
@ 2026-10-14 21:26 Andrew Morton
0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2026-10-14 21:26 UTC (permalink / raw)
To: mm-commits, vbabka, surenb, shuah, rppt, mhocko, ljs, liam, david,
ricardo, akpm
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 3529 bytes --]
The patch titled
Subject: selftests/mm: mremap_test: Validate the preamble region before mapping it
has been added to the -mm mm-unstable branch. Its filename is
selftests-mm-mremap_test-validate-the-preamble-region-before-mapping-it.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/selftests-mm-mremap_test-validate-the-preamble-region-before-mapping-it.patch
This patch will later appear in the mm-unstable branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days
------------------------------------------------------
From: Ricardo B. Marlière (SUSE) <ricardo@marliere.net>
Subject: selftests/mm: mremap_test: Validate the preamble region before mapping it
Date: Wed, 14 Oct 2026 15:46:46 -0300
remap_region() checks that the destination region is free before mapping
it, but not the preamble region placed right before it, so mapping the
preamble can intermittently fail with EEXIST:
# Failed to map dest preamble region: File exists
not ok 15 5MB mremap - Source 1MB-aligned, Dest 1MB-aligned with 40MB Preamble
This happens when the kernel's heap ASLR (arch_randomize_brk()) lands the
process heap inside that unchecked range. Confirmed by correlating
brk(NULL) at startup with pass/fail across 60 runs: every failure had brk
land inside that range.
Fix it by including the preamble in the free-region check.
Link: https://lore.kernel.org/20261014-selftests-mm-mremap_preamble-v1-1-2e97f501cb56@marliere.net
Signed-off-by: Ricardo B. Marlière (SUSE) <ricardo@marliere.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: David Hildenbrand <david@kernel.org>
Cc: Lorenzo Stoakes <ljs@kernel.org>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Shuah Khan <shuah@kernel.org>
---
tools/testing/selftests/mm/mremap_test.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
--- a/tools/testing/selftests/mm/mremap_test.c~selftests-mm-mremap_test-validate-the-preamble-region-before-mapping-it
+++ a/tools/testing/selftests/mm/mremap_test.c
@@ -1006,8 +1006,10 @@ static long long remap_region(struct con
if (!((unsigned long long) addr & c.dest_alignment))
addr = (void *) ((unsigned long long) addr | c.dest_alignment);
- /* Don't destroy existing mappings unless expected to overlap */
- while (!is_remap_region_valid(addr, c.region_size) && !c.overlapping) {
+ /* Don't destroy existing mappings unless expected to overlap. */
+ while (!is_remap_region_valid(addr - c.dest_preamble_size,
+ c.dest_preamble_size + c.region_size) &&
+ !c.overlapping) {
/* Check for unsigned overflow */
tmp_addr = addr + c.dest_alignment;
if (tmp_addr < addr) {
_
Patches currently in -mm which might be from ricardo@marliere.net are
selftests-mm-mremap_test-validate-the-preamble-region-before-mapping-it.patch
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-14 21:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-14 21:26 + selftests-mm-mremap_test-validate-the-preamble-region-before-mapping-it.patch added to mm-unstable branch Andrew Morton
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.