mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sarthak Sharma <sarthak.sharma@arm.com>
To: "Ricardo B. Marlière (SUSE)" <ricardo@marliere.net>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"David Hildenbrand" <david@kernel.org>,
	"Lorenzo Stoakes" <ljs@kernel.org>,
	"Liam R. Howlett" <liam@infradead.org>,
	"Vlastimil Babka" <vbabka@kernel.org>,
	"Mike Rapoport" <rppt@kernel.org>,
	"Suren Baghdasaryan" <surenb@google.com>,
	"Michal Hocko" <mhocko@suse.com>, "Shuah Khan" <shuah@kernel.org>
Cc: linux-mm@kvack.org, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] selftests/mm: mremap_test: Validate the preamble region before mapping it
Date: Thu, 15 Oct 2026 11:44:29 +0530	[thread overview]
Message-ID: <3d43e4bd-7065-4ae1-bbc9-b034a9de531f@arm.com> (raw)
In-Reply-To: <20261014-selftests-mm-mremap_preamble-v1-1-2e97f501cb56@marliere.net>



On 10/15/26 12:16 AM, Ricardo B. Marlière (SUSE) wrote:
> 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.
> 
> Signed-off-by: Ricardo B. Marlière (SUSE) <ricardo@marliere.net>
> ---

Just wondering, should this have a Fixes: tag as well?

Other than that, LGTM.

Reviewed-by: Sarthak Sharma <sarthak.sharma@arm.com>

> Hi, this sporadic issue has been found in openSUSE CI:
> 
> https://openqa.opensuse.org/tests/6270334/logfile?filename=serial_terminal.txt#line-6760
> ---
>  tools/testing/selftests/mm/mremap_test.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/testing/selftests/mm/mremap_test.c b/tools/testing/selftests/mm/mremap_test.c
> index 131d9d6db867..8d4fa3025a9d 100644
> --- a/tools/testing/selftests/mm/mremap_test.c
> +++ b/tools/testing/selftests/mm/mremap_test.c
> @@ -1006,8 +1006,10 @@ static long long remap_region(struct config c, unsigned int threshold_mb,
>  	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) {
> 
> ---
> base-commit: 0fcb05b72344f40806cbe810de8872f1698bf053
> change-id: 20261014-selftests-mm-mremap_preamble-5f98ad625f93
> 
> Best regards,
> --  
> Ricardo B. Marlière (SUSE) <ricardo@marliere.net>


      reply	other threads:[~2026-10-15  6:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-14 18:46 Ricardo B. Marlière (SUSE)
2026-10-15  6:14 ` Sarthak Sharma [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3d43e4bd-7065-4ae1-bbc9-b034a9de531f@arm.com \
    --to=sarthak.sharma@arm.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@kernel.org \
    --cc=liam@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=mhocko@suse.com \
    --cc=ricardo@marliere.net \
    --cc=rppt@kernel.org \
    --cc=shuah@kernel.org \
    --cc=surenb@google.com \
    --cc=vbabka@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®