[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20241218153615.2267571-1-kevin.brodsky@arm.com>
Date: Wed, 18 Dec 2024 15:36:15 +0000
From: Kevin Brodsky <kevin.brodsky@....com>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: linux-kernel@...r.kernel.org,
Kevin Brodsky <kevin.brodsky@....com>,
kernel test robot <lkp@...el.com>,
aruna.ramakrishna@...cle.com,
catalin.marinas@....com,
dave.hansen@...ux.intel.com,
joey.gouly@....com,
keith.lucas@...cle.com,
ryan.roberts@....com,
shuah@...nel.org,
linux-arm-kernel@...ts.infradead.org,
linux-kselftest@...r.kernel.org,
linux-mm@...ck.org,
x86@...nel.org
Subject: [PATCH] selftests/mm: Fix -Wnull-dereference on Clang
Dereferencing a null pointer on Clang is not a good idea - it will
entirely optimise out the dereference. Make the pointer volatile to
force the access (and fault).
Reported-by: kernel test robot <lkp@...el.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202412140850.4TW4YBqc-lkp@intel.com/
Signed-off-by: Kevin Brodsky <kevin.brodsky@....com>
---
Hi Andrew,
Another fixup for an issue reported by the LKP CI (building with Clang
instead of GCC). This should be squashed into the patch I'm replying to:
"selftests/mm: Fix -Warray-bounds warnings in pkey_sighandler_tests"
Cheers,
- Kevin
Cc: aruna.ramakrishna@...cle.com
Cc: catalin.marinas@....com
Cc: dave.hansen@...ux.intel.com
Cc: joey.gouly@....com
Cc: keith.lucas@...cle.com
Cc: ryan.roberts@....com
Cc: shuah@...nel.org
Cc: linux-arm-kernel@...ts.infradead.org
Cc: linux-kselftest@...r.kernel.org
Cc: linux-mm@...ck.org
Cc: x86@...nel.org
---
tools/testing/selftests/mm/pkey_sighandler_tests.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/mm/pkey_sighandler_tests.c b/tools/testing/selftests/mm/pkey_sighandler_tests.c
index 17bbfcd552c6..1ac8c8809880 100644
--- a/tools/testing/selftests/mm/pkey_sighandler_tests.c
+++ b/tools/testing/selftests/mm/pkey_sighandler_tests.c
@@ -161,7 +161,7 @@ static void *thread_segv_with_pkey0_disabled(void *ptr)
__write_pkey_reg(pkey_reg_restrictive_default());
/* Segfault (with SEGV_MAPERR) */
- *(int *)NULL = 1;
+ *(volatile int *)NULL = 1;
return NULL;
}
@@ -192,7 +192,7 @@ static void *thread_segv_maperr_ptr(void *ptr)
__write_pkey_reg(pkey_reg);
/* Segfault */
- *(int *)NULL = 1;
+ *(volatile int *)NULL = 1;
syscall_raw(SYS_exit, 0, 0, 0, 0, 0, 0);
return NULL;
}
--
2.47.0
Powered by blists - more mailing lists