The commit is pushed to "branch-rh10-6.12.0-55.52.1.4.x.vz10-ovz" and will
appear at [email protected]:openvz/vzkernel.git
after rh10-6.12.0-55.52.1.4.11.vz10
------>
commit 5991b695fea6bd4cb52b82bf7c29411acc16db5f
Author: Kevin Brodsky <[email protected]>
Date: Mon Mar 23 18:07:33 2026 +0100
ms/selftests/mm: fix -Warray-bounds warnings in pkey_sighandler_tests
GCC doesn't like dereferencing a pointer set to 0x1 (when building
at -O2):
pkey_sighandler_tests.c:166:9: warning: array subscript 0 is outside array
bounds of 'int[0]' [-Warray-bounds=]
166 | *(int *) (0x1) = 1;
| ^~~~~~~~~~~~~~
cc1: note: source object is likely at address zero
Using NULL instead seems to make it happy. This should make no difference
in practice (SIGSEGV with SEGV_MAPERR will be the outcome regardless), we
just need to update the expected si_addr.
[[email protected]: fix clang dereferencing-null issue]
Link:
https://lkml.kernel.org/r/[email protected]
Link:
https://lkml.kernel.org/r/[email protected]
Signed-off-by: Kevin Brodsky <[email protected]>
Cc: Aruna Ramakrishna <[email protected]>
Cc: Catalin Marinas <[email protected]>
Cc: Dave Hansen <[email protected]>
Cc: Joey Gouly <[email protected]>
Cc: Keith Lucas <[email protected]>
Cc: Ryan Roberts <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: kernel test robot <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
(cherry picked from commit 71384f84cbbe7660023b01c1a0fa9cc7dbc487a7)
Conflict in pkey_sighandler_tests.c: removed unused `int *bad` variable
declaration â our branch already uses hardcoded pkey_reg values instead
of pkey_reg_restrictive_default(), so neither `int *bad` nor `u64 pkey_reg`
are needed.
https://virtuozzo.atlassian.net/browse/VSTOR-127529
Signed-off-by: Konstantin Khorenko <[email protected]>
Reviewed-by: Pavel Tikhomirov <[email protected]>
Reviewed-by: Vasileios Almpanis <[email protected]>
Feature: fix selftests
---
tools/testing/selftests/mm/pkey_sighandler_tests.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/tools/testing/selftests/mm/pkey_sighandler_tests.c
b/tools/testing/selftests/mm/pkey_sighandler_tests.c
index a8088b645ad6d..62f2ab8b440a4 100644
--- a/tools/testing/selftests/mm/pkey_sighandler_tests.c
+++ b/tools/testing/selftests/mm/pkey_sighandler_tests.c
@@ -116,7 +116,7 @@ static void *thread_segv_with_pkey0_disabled(void *ptr)
__write_pkey_reg(0x55555555);
/* Segfault (with SEGV_MAPERR) */
- *(int *) (0x1) = 1;
+ *(volatile int *)NULL = 1;
return NULL;
}
@@ -132,7 +132,6 @@ static void *thread_segv_pkuerr_stack(void *ptr)
static void *thread_segv_maperr_ptr(void *ptr)
{
stack_t *stack = ptr;
- int *bad = (int *)1;
/*
* Setup alternate signal stack, which should be pkey_mprotect()ed by
@@ -145,7 +144,7 @@ static void *thread_segv_maperr_ptr(void *ptr)
__write_pkey_reg(0x55555551);
/* Segfault */
- *bad = 1;
+ *(volatile int *)NULL = 1;
syscall_raw(SYS_exit, 0, 0, 0, 0, 0, 0);
return NULL;
}
@@ -184,7 +183,7 @@ static void test_sigsegv_handler_with_pkey0_disabled(void)
ksft_test_result(siginfo.si_signo == SIGSEGV &&
siginfo.si_code == SEGV_MAPERR &&
- siginfo.si_addr == (void *)1,
+ siginfo.si_addr == NULL,
"%s\n", __func__);
}
@@ -296,7 +295,7 @@ static void
test_sigsegv_handler_with_different_pkey_for_stack(void)
ksft_test_result(siginfo.si_signo == SIGSEGV &&
siginfo.si_code == SEGV_MAPERR &&
- siginfo.si_addr == (void *)1,
+ siginfo.si_addr == NULL,
"%s\n", __func__);
}
_______________________________________________
Devel mailing list
[email protected]
https://lists.openvz.org/mailman/listinfo/devel