Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ARM: 9290/1: uaccess: Fix KASAN false-positives

__copy_to_user_memcpy() and __clear_user_memset() had been calling
memcpy() and memset() respectively, leading to false-positive KASAN
reports when starting userspace:

[ 10.707901] Run /init as init process
[ 10.731892] process '/bin/busybox' started with executable stack
[ 10.745234] ==================================================================
[ 10.745796] BUG: KASAN: user-memory-access in __clear_user_memset+0x258/0x3ac
[ 10.747260] Write of size 2687 at addr 000de581 by task init/1

Use __memcpy() and __memset() instead to allow userspace access, which
is of course the intent of these functions.

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>

authored by

Andrew Jeffery and committed by
Russell King (Oracle)
ceac10c8 c9c3395d

+2 -2
+2 -2
arch/arm/lib/uaccess_with_memcpy.c
··· 116 116 tocopy = n; 117 117 118 118 ua_flags = uaccess_save_and_enable(); 119 - memcpy((void *)to, from, tocopy); 119 + __memcpy((void *)to, from, tocopy); 120 120 uaccess_restore(ua_flags); 121 121 to += tocopy; 122 122 from += tocopy; ··· 178 178 tocopy = n; 179 179 180 180 ua_flags = uaccess_save_and_enable(); 181 - memset((void *)addr, 0, tocopy); 181 + __memset((void *)addr, 0, tocopy); 182 182 uaccess_restore(ua_flags); 183 183 addr += tocopy; 184 184 n -= tocopy;