lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250828063211.h-gpZAEb@linutronix.de>
Date: Thu, 28 Aug 2025 08:32:11 +0200
From: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
To: Waiman Long <llong@...hat.com>
Cc: André Almeida <andrealmeid@...lia.com>,
	linux-kernel@...r.kernel.org, Darren Hart <dvhart@...radead.org>,
	Davidlohr Bueso <dave@...olabs.net>, Ingo Molnar <mingo@...hat.com>,
	Juri Lelli <juri.lelli@...hat.com>,
	Peter Zijlstra <peterz@...radead.org>,
	Thomas Gleixner <tglx@...utronix.de>,
	Valentin Schneider <vschneid@...hat.com>,
	Borislav Petkov <bp@...en8.de>, kernel-dev@...lia.com
Subject: Re: [PATCH] selftests/futex: Fix futex_numa_mpol's memory out of
 range subtest

On 2025-08-27 13:58:50 [-0400], Waiman Long wrote:
> On 8/27/25 11:44 AM, André Almeida wrote:
> > --- a/tools/testing/selftests/futex/functional/futex_numa_mpol.c
> > +++ b/tools/testing/selftests/futex/functional/futex_numa_mpol.c
> > @@ -168,6 +168,17 @@ int main(int argc, char *argv[])
> >   	ksft_set_plan(1);
> >   	mem_size = sysconf(_SC_PAGE_SIZE);
> > +
> > +	/*
> > +	 * The "Memory out of range" test depends on having a pointer to an
> > +	 * invalid address. To make this test deterministic, and to not depend
> > +	 * on the memory layout of the process, create a "buffer zone" with
> > +	 * PROT_NONE just before the valid memory (*futex_ptr).
> > +	 */
> > +	buffer_zone = mmap(NULL, mem_size, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
> > +	if (buffer_zone == MAP_FAILED)
> > +		ksft_exit_fail_msg("mmap() for %d bytes failed\n", mem_size);
> > +
> >   	futex_ptr = mmap(NULL, mem_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
> >   	if (futex_ptr == MAP_FAILED)
> >   		ksft_exit_fail_msg("mmap() for %d bytes failed\n", mem_size);
> 
> This patch makes the assumption that consecutive mmap() calls will allocate
> pages consecutively downward from a certain address. I don't know if this
> assumption will be valid in all cases. I think it will be safer to just
> allocate the 2-page memory block and then change the 2nd page protection to
> PROT_NONE to make it a guard page.

You shouldn't make any assumption about mmap()'s returned pointer unless
you pass it as the addr argument and expect it to be followed.
Using two pages and making the second a guard page sounds sane.

> Cheers,
> Longman

Sebastian

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ