OrangePi_CM5/arch/x86/lib
Mikulas Patocka 80fc45377f x86: __memcpy_flushcache: fix wrong alignment if size > 2^32
[ Upstream commit a6823e4e360fe975bd3da4ab156df7c74c8b07f3 ]

The first "if" condition in __memcpy_flushcache is supposed to align the
"dest" variable to 8 bytes and copy data up to this alignment.  However,
this condition may misbehave if "size" is greater than 4GiB.

The statement min_t(unsigned, size, ALIGN(dest, 8) - dest); casts both
arguments to unsigned int and selects the smaller one.  However, the
cast truncates high bits in "size" and it results in misbehavior.

For example:

	suppose that size == 0x100000001, dest == 0x200000002
	min_t(unsigned, size, ALIGN(dest, 8) - dest) == min_t(0x1, 0xe) == 0x1;
	...
	dest += 0x1;

so we copy just one byte "and" dest remains unaligned.

This patch fixes the bug by replacing unsigned with size_t.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-05-09 09:05:06 +02:00
..
.gitignore
…
Makefile
…
atomic64_32.c
…
atomic64_386_32.S
…
atomic64_cx8_32.S
…
cache-smp.c
…
checksum_32.S
…
clear_page_64.S
…
cmdline.c
…
cmpxchg8b_emu.S
…
cmpxchg16b_emu.S
…
copy_mc.c
…
copy_mc_64.S
…
copy_page_64.S
…
copy_user_64.S
…
cpu.c
…
csum-copy_64.S
…
csum-partial_64.c
…
csum-wrappers_64.c
…
delay.c
…
error-inject.c
…
getuser.S
…
hweight.S
…
inat.c
…
insn-eval.c x86/iopl: Fake iopl(3) CLI/STI usage 2021-11-21 13:46:36 +01:00
insn.c
…
iomap_copy_64.S
…
iomem.c
…
kaslr.c
…
memcpy_32.c
…
memcpy_64.S
…
memmove_64.S
…
memset_64.S
…
misc.c
…
mmx_32.c
…
msr-reg-export.c
…
msr-reg.S
…
msr-smp.c
…
msr.c
…
putuser.S
…
retpoline.S
…
string_32.c
…
strstr_32.c
…
usercopy.c
…
usercopy_32.c
…
usercopy_64.c x86: __memcpy_flushcache: fix wrong alignment if size > 2^32 2022-05-09 09:05:06 +02:00
x86-opcode-map.txt
…