linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fix comparison of unsigned expression < 0
@ 2023-11-28  7:55 Haibo Li
  2023-11-29  1:22 ` Andrew Morton
  0 siblings, 1 reply; 6+ messages in thread
From: Haibo Li @ 2023-11-28  7:55 UTC (permalink / raw)
  To: linux-kernel
  Cc: Andrey Ryabinin, Alexander Potapenko, Andrey Konovalov,
	Dmitry Vyukov, Vincenzo Frascino, Andrew Morton,
	Matthias Brugger, AngeloGioacchino Del Regno, kasan-dev,
	linux-mm, linux-arm-kernel, linux-mediatek, xiaoming.yu,
	Haibo Li, kernel test robot

Kernel test robot reported:

'''
mm/kasan/report.c:637 kasan_non_canonical_hook() warn:
unsigned 'addr' is never less than zero.
'''
The KASAN_SHADOW_OFFSET is 0 on loongarch64.

To fix it,check the KASAN_SHADOW_OFFSET before do comparison.

Signed-off-by: Haibo Li <haibo.li@mediatek.com>
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/
  202311270743.3oTCwYPd-lkp@intel.com/
---
 mm/kasan/report.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/kasan/report.c b/mm/kasan/report.c
index e77facb62900..dafec2df0268 100644
--- a/mm/kasan/report.c
+++ b/mm/kasan/report.c
@@ -634,10 +634,10 @@ void kasan_non_canonical_hook(unsigned long addr)
 {
 	unsigned long orig_addr;
 	const char *bug_type;
-
+#if KASAN_SHADOW_OFFSET > 0
 	if (addr < KASAN_SHADOW_OFFSET)
 		return;
-
+#endif
 	orig_addr = (addr - KASAN_SHADOW_OFFSET) << KASAN_SHADOW_SCALE_SHIFT;
 	/*
 	 * For faults near the shadow address for NULL, we can be fairly certain
-- 
2.18.0



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-12-13 15:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-28  7:55 [PATCH] fix comparison of unsigned expression < 0 Haibo Li
2023-11-29  1:22 ` Andrew Morton
2023-11-29  3:01   ` Andrey Konovalov
2023-11-29  3:42     ` Haibo Li
2023-12-04  4:12     ` Dan Carpenter
2023-12-13 15:31       ` Andrey Konovalov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox