diff options
author | Peter Zijlstra | 2019-04-24 09:19:25 +0200 |
---|---|---|
committer | Greg Kroah-Hartman | 2019-05-31 15:46:16 +0200 |
commit | 189b396a2580d6174996edbd5f5bbbe1d34dd29f (patch) | |
tree | 2ae535714ed8a9829749fd1f63e5f87d3229ba6c /lib/strnlen_user.c | |
parent | x86/mm: Remove in_nmi() warning from 64-bit implementation of vmalloc_fault() (diff) | |
download | kernel-qcow2-linux-189b396a2580d6174996edbd5f5bbbe1d34dd29f.tar.gz kernel-qcow2-linux-189b396a2580d6174996edbd5f5bbbe1d34dd29f.tar.xz kernel-qcow2-linux-189b396a2580d6174996edbd5f5bbbe1d34dd29f.zip |
mm/uaccess: Use 'unsigned long' to placate UBSAN warnings on older GCC versions
[ Upstream commit 29da93fea3ea39ab9b12270cc6be1b70ef201c9e ]
Randy reported objtool triggered on his (GCC-7.4) build:
lib/strncpy_from_user.o: warning: objtool: strncpy_from_user()+0x315: call to __ubsan_handle_add_overflow() with UACCESS enabled
lib/strnlen_user.o: warning: objtool: strnlen_user()+0x337: call to __ubsan_handle_sub_overflow() with UACCESS enabled
This is due to UBSAN generating signed-overflow-UB warnings where it
should not. Prior to GCC-8 UBSAN ignored -fwrapv (which the kernel
uses through -fno-strict-overflow).
Make the functions use 'unsigned long' throughout.
Reported-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Randy Dunlap <rdunlap@infradead.org> # build-tested
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: luto@kernel.org
Link: http://lkml.kernel.org/r/20190424072208.754094071@infradead.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'lib/strnlen_user.c')
-rw-r--r-- | lib/strnlen_user.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c index 60d0bbda8f5e..184f80f7bacf 100644 --- a/lib/strnlen_user.c +++ b/lib/strnlen_user.c @@ -28,7 +28,7 @@ static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max) { const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS; - long align, res = 0; + unsigned long align, res = 0; unsigned long c; /* @@ -42,7 +42,7 @@ static inline long do_strnlen_user(const char __user *src, unsigned long count, * Do everything aligned. But that means that we * need to also expand the maximum.. */ - align = (sizeof(long) - 1) & (unsigned long)src; + align = (sizeof(unsigned long) - 1) & (unsigned long)src; src -= align; max += align; |