Skip to content

Commit 02b32ac

Browse files
committed
selftest/futex: Reintroduce "Memory out of range" numa_mpol's subtest
JIRA: https://issues.redhat.com/browse/RHEL-101190 commit 2951ddd Author: André Almeida <andrealmeid@igalia.com> Date: Mon, 15 Sep 2025 23:26:29 +0200 selftest/futex: Reintroduce "Memory out of range" numa_mpol's subtest Commit d8e2f91 ("selftests/futex: Fix some futex_numa_mpol subtests") removed the "Memory out of range" subtest due to it being dependent on the memory layout of the test process having an invalid memory address just after the `*futex_ptr` allocated memory. Reintroduce this test and make it deterministic, by allocation two memory pages and marking the second one with PROT_NONE. Signed-off-by: André Almeida <andrealmeid@igalia.com> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Waiman Long <longman@redhat.com> Signed-off-by: Waiman Long <longman@redhat.com>
1 parent 9f07fb3 commit 02b32ac

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

tools/testing/selftests/futex/functional/futex_numa_mpol.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,13 @@ int main(int argc, char *argv[])
174174
ksft_set_plan(1);
175175

176176
mem_size = sysconf(_SC_PAGE_SIZE);
177-
futex_ptr = mmap(NULL, mem_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
177+
futex_ptr = mmap(NULL, mem_size * 2, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
178178
if (futex_ptr == MAP_FAILED)
179179
ksft_exit_fail_msg("mmap() for %d bytes failed\n", mem_size);
180180

181+
/* Create an invalid memory region for the "Memory out of range" test */
182+
mprotect(futex_ptr + mem_size, mem_size, PROT_NONE);
183+
181184
futex_numa = futex_ptr;
182185

183186
ksft_print_msg("Regular test\n");
@@ -192,6 +195,9 @@ int main(int argc, char *argv[])
192195
ksft_print_msg("Mis-aligned futex\n");
193196
test_futex(futex_ptr + mem_size - 4, EINVAL);
194197

198+
ksft_print_msg("Memory out of range\n");
199+
test_futex(futex_ptr + mem_size, EFAULT);
200+
195201
futex_numa->numa = FUTEX_NO_NODE;
196202
mprotect(futex_ptr, mem_size, PROT_READ);
197203
ksft_print_msg("Memory, RO\n");

0 commit comments

Comments
 (0)