WSL2-Linux-Kernel/arch/arm/lib
Kursad Oney c24a3c9e37 ARM: 9321/1: memset: cast the constant byte to unsigned char
[ Upstream commit c0e824661f443b8cab3897006c1bbc69fd0e7bc4 ]

memset() description in ISO/IEC 9899:1999 (and elsewhere) says:

	The memset function copies the value of c (converted to an
	unsigned char) into each of the first n characters of the
	object pointed to by s.

The kernel's arm32 memset does not cast c to unsigned char. This results
in the following code to produce erroneous output:

	char a[128];
	memset(a, -128, sizeof(a));

This is because gcc will generally emit the following code before
it calls memset() :

	mov   r0, r7
	mvn   r1, #127        ; 0x7f
	bl    00000000 <memset>

r1 ends up with 0xffffff80 before being used by memset() and the
'a' array will have -128 once in every four bytes while the other
bytes will be set incorrectly to -1 like this (printing the first
8 bytes) :

	test_module: -128 -1 -1 -1
	test_module: -1 -1 -1 -128

The change here is to 'and' r1 with 255 before it is used.

Fixes: 1da177e4c3 ("Linux-2.6.12-rc2")
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Kursad Oney <kursad.oney@broadcom.com>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:08:23 +01:00
..
Makefile ARM: 8900/1: UNWINDER_FRAME_POINTER implementation for Clang 2019-08-29 07:58:01 +01:00
ashldi3.S Revert "arm: move exports to definitions" 2016-11-23 10:00:03 +00:00
ashrdi3.S Revert "arm: move exports to definitions" 2016-11-23 10:00:03 +00:00
backtrace-clang.S printk: Userspace format indexing support 2021-07-19 11:57:48 +02:00
backtrace.S printk: Userspace format indexing support 2021-07-19 11:57:48 +02:00
bitops.h locking/atomic: arm: fix sync ops 2023-07-23 13:46:48 +02:00
bswapsdi2.S License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
call_with_stack.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 333 2019-06-05 17:37:06 +02:00
changebit.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
clear_user.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
clearbit.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
copy_from_user.S ARM: 9113/1: uaccess: remove set_fs() implementation 2021-08-20 11:39:27 +01:00
copy_page.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
copy_template.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
copy_to_user.S ARM: 9113/1: uaccess: remove set_fs() implementation 2021-08-20 11:39:27 +01:00
csumipv6.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
csumpartial.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
csumpartialcopy.S arm: propagate the calling convention changes down to csum_partial_copy_from_user() 2020-08-20 15:45:16 -04:00
csumpartialcopygeneric.S arm: propagate the calling convention changes down to csum_partial_copy_from_user() 2020-08-20 15:45:16 -04:00
csumpartialcopyuser.S arm: propagate the calling convention changes down to csum_partial_copy_from_user() 2020-08-20 15:45:16 -04:00
delay-loop.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
delay.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 333 2019-06-05 17:37:06 +02:00
div64.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
findbit.S ARM: findbit: fix overflowing offset 2022-08-17 14:23:05 +02:00
getuser.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
io-readsb.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
io-readsl.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
io-readsw-armv3.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
io-readsw-armv4.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
io-writesb.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
io-writesl.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
io-writesw-armv3.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
io-writesw-armv4.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
lib1funcs.S ARM: 8844/1: use unified assembler in assembly files 2019-02-26 11:26:07 +00:00
lshrdi3.S Revert "arm: move exports to definitions" 2016-11-23 10:00:03 +00:00
memchr.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
memcpy.S ARM: 9022/1: Change arch/arm/lib/mem*.S to use WEAK instead of .weak 2020-11-12 14:53:19 +00:00
memmove.S ARM: 9022/1: Change arch/arm/lib/mem*.S to use WEAK instead of .weak 2020-11-12 14:53:19 +00:00
memset.S ARM: 9321/1: memset: cast the constant byte to unsigned char 2023-11-20 11:08:23 +01:00
muldi3.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
putuser.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
setbit.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
strchr.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
strrchr.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
testchangebit.S locking/atomic: arm: fix sync ops 2023-07-23 13:46:48 +02:00
testclearbit.S locking/atomic: arm: fix sync ops 2023-07-23 13:46:48 +02:00
testsetbit.S locking/atomic: arm: fix sync ops 2023-07-23 13:46:48 +02:00
uaccess_with_memcpy.c ARM: 9290/1: uaccess: Fix KASAN false-positives 2023-04-20 12:13:54 +02:00
ucmpdi2.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
xor-neon.c ARM: crypto: comment out gcc warning that breaks clang builds 2022-08-03 12:03:54 +02:00