android_kernel_motorola_sm6225/arch
Kursad Oney 7b0e690456 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 10:29:19 +01:00
..
alpha alpha: remove __init annotation from exported page_is_ram() 2023-08-16 18:13:01 +02:00
arc ARC: define ASM_NL and __ALIGN(_STR) outside #ifdef __ASSEMBLY__ guard 2023-08-11 11:45:11 +02:00
arm ARM: 9321/1: memset: cast the constant byte to unsigned char 2023-11-20 10:29:19 +01:00
arm64 arm64: fix a concurrency issue in emulation_proc_handler() 2023-11-08 11:22:17 +01:00
c6x
h8300 h8300: Fix build errors from do_exit() to make_task_dead() transition 2023-02-06 07:49:45 +01:00
hexagon hexagon: Fix function name in die() 2023-02-06 07:49:45 +01:00
ia64 treewide: Remove uninitialized_var() usage 2023-08-11 11:45:01 +02:00
m68k m68k: Fix invalid .section syntax 2023-09-23 10:47:57 +02:00
microblaze exit: Add and use make_task_dead. 2023-02-06 07:49:45 +01:00
mips MIPS: Alchemy: only build mmc support helpers if au1xmmc is enabled 2023-10-10 21:44:58 +02:00
nds32 exit: Add and use make_task_dead. 2023-02-06 07:49:45 +01:00
nios2 nios2: dts: Fix tse_mac "max-frame-size" property 2023-06-21 15:39:57 +02:00
openrisc openrisc: Properly store r31 to pt_regs on unhandled exceptions 2023-05-17 11:13:19 +02:00
parisc parisc: Restore __ldcw_align for PA-RISC 2.0 processors 2023-10-10 21:45:02 +02:00
powerpc powerpc/64e: Fix wrong test in __ptep_test_and_clear_young() 2023-10-25 11:16:36 +02:00
riscv riscv: Bump COMMAND_LINE_SIZE value to 1024 2023-04-05 11:15:36 +02:00
s390 s390/pci: fix iommu bitmap allocation 2023-10-25 11:17:02 +02:00
sh sh: dma: Fix DMA channel offset calculation 2023-08-11 11:45:14 +02:00
sparc sparc: fix up arch_cpu_finalize_init() build breakage. 2023-08-16 18:12:59 +02:00
um um: Fix hostaudio build errors 2023-09-23 10:48:09 +02:00
unicore32
x86 x86: Fix .brk attribute in linker script 2023-11-08 11:22:19 +01:00
xtensa xtensa: ISS: fix call to split_if_spec 2023-08-11 11:45:23 +02:00
.gitignore
Kconfig init: Provide arch_cpu_finalize_init() 2023-08-08 19:49:17 +02:00