android_kernel_asus_sm8350/arch
Kursad Oney 454e6493bb 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:30:12 +01:00
..
alpha alpha: remove __init annotation from exported page_is_ram() 2023-08-16 18:19:25 +02:00
arc ARC: define ASM_NL and __ALIGN(_STR) outside #ifdef __ASSEMBLY__ guard 2023-07-27 08:37:18 +02:00
arm ARM: 9321/1: memset: cast the constant byte to unsigned char 2023-11-20 10:30:12 +01:00
arm64 arm64: dts: qcom: sdm845-mtp: fix WiFi configuration 2023-11-20 10:30:11 +01:00
c6x dma-mapping: drop the dev argument to arch_sync_dma_for_* 2023-04-05 11:16:43 +02:00
csky dma-mapping: drop the dev argument to arch_sync_dma_for_* 2023-04-05 11:16:43 +02:00
h8300 h8300: Fix build errors from do_exit() to make_task_dead() transition 2023-02-06 07:52:49 +01:00
hexagon dma-mapping: drop the dev argument to arch_sync_dma_for_* 2023-04-05 11:16:43 +02:00
ia64 ia64/cpu: Switch to arch_cpu_finalize_init() 2023-08-08 19:56:34 +02:00
m68k m68k: Fix invalid .section syntax 2023-09-23 10:59:38 +02:00
microblaze dma-mapping: drop the dev argument to arch_sync_dma_for_* 2023-04-05 11:16:43 +02:00
mips MIPS: Alchemy: only build mmc support helpers if au1xmmc is enabled 2023-10-10 21:46:38 +02:00
nds32 dma-mapping: drop the dev argument to arch_sync_dma_for_* 2023-04-05 11:16:43 +02:00
nios2 nios2: dts: Fix tse_mac "max-frame-size" property 2023-06-21 15:44:10 +02:00
openrisc openrisc: Properly store r31 to pt_regs on unhandled exceptions 2023-05-17 11:35:53 +02:00
parisc parisc: Restore __ldcw_align for PA-RISC 2.0 processors 2023-10-10 21:46:45 +02:00
powerpc powerpc/64e: Fix wrong test in __ptep_test_and_clear_young() 2023-10-25 11:53:20 +02:00
riscv riscv: Bump COMMAND_LINE_SIZE value to 1024 2023-04-05 11:16:39 +02:00
s390 s390/pci: fix iommu bitmap allocation 2023-10-25 11:53:24 +02:00
sh sh: boards: Fix CEU buffer size passed to dma_declare_coherent_memory() 2023-09-23 10:59:59 +02:00
sparc sparc/cpu: Switch to arch_cpu_finalize_init() 2023-08-08 19:56:34 +02:00
um um: Fix hostaudio build errors 2023-09-23 10:59:53 +02:00
unicore32 mm: treewide: clarify pgtable_page_{ctor,dtor}() naming 2019-09-26 10:10:44 -07:00
x86 x86: Fix .brk attribute in linker script 2023-11-08 11:23:40 +01:00
xtensa xtensa: boot/lib: fix function prototypes 2023-10-10 21:46:39 +02:00
.gitignore
Kconfig init: Provide arch_cpu_finalize_init() 2023-08-08 19:56:33 +02:00