[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <336a1a43-54ac-4f53-b3a8-5e46f6d45359@igalia.com>
Date: Tue, 19 Aug 2025 09:22:49 -0300
From: André Almeida <andrealmeid@...lia.com>
To: Waiman Long <longman@...hat.com>
Cc: linux-kernel@...r.kernel.org,
Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
Peter Zijlstra <peterz@...radead.org>, Shuah Khan <shuah@...nel.org>,
Ingo Molnar <mingo@...nel.org>, Thomas Gleixner <tglx@...utronix.de>,
linux-kselftest@...r.kernel.org, Colin Ian King <colin.i.king@...il.com>,
Darren Hart <dvhart@...radead.org>, Davidlohr Bueso <dave@...olabs.net>
Subject: Re: [PATCH] selftests/futex: Fix some futex_numa_mpol subtests
Hi Waiman,
Em 10/08/2025 19:27, Waiman Long escreveu:
> The "Memory out of range" subtest of futex_numa_mpol assumes that memory
> access outside of the mmap'ed area is invalid. That may not be the case
> depending on the actual memory layout of the test application. When
> that subtest was run on an x86-64 system with latest upstream kernel,
> the test passed as an error was returned from futex_wake(). On another
> powerpc system, the same subtest failed because futex_wake() returned 0.
>
> Bail out! futex2_wake(64, 0x86) should fail, but didn't
>
> Looking further into the passed subtest on x86-64, it was found that an
> -EINVAL was returned instead of -EFAULT. The -EINVAL error was returned
> because the node value test with FLAGS_NUMA set failed with a node value
> of 0x7f7f. IOW, the futex memory was accessible and futex_wake() failed
> because the supposed node number wasn't valid. If that memory location
> happens to have a very small value (e.g. 0), the test will pass and no
> error will be returned.
>
> Since this subtest is non-deterministic, it is dropped unless we
> explicitly set a guard page beyond the mmap region.
>
>
I had proposed a refactor of the futex selftests[1] and I spotted the
same issue with the memory out of range test. My solution for this was
to create a "buffer zone" with PROT_NONE to ensure that I would have a
invalid memory access:
/*
* test_harness_run() calls mmap(..., MAP_SHARED, ...), which can create
* a valid access memory region just bellow the mmap() issue here. Then,
* the test for "Memory out of range" will fail because it will succeed
* accessing the memory address after the range. To avoid this we create
* a "Buffer zone" with PROT_NONE between the two mmap's.
*/
buffer_zone = mmap(NULL, mem_size, PROT_NONE, MAP_PRIVATE |
MAP_ANONYMOUS, 0, 0);
[1]
https://lore.kernel.org/lkml/20250704-tonyk-robust_test_cleanup-v1-13-c0ff4f24c4e1@igalia.com/
Powered by blists - more mailing lists