linux-stable/arch/x86
Mikulas Patocka 4640802e1c x86: __memcpy_flushcache: fix wrong alignment if size > 2^32
[ Upstream commit a6823e4e36 ]

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:14:40 +02:00
..
boot x86/boot/compressed: Move CLANG_FLAGS to beginning of KBUILD_CFLAGS 2022-01-27 11:03:47 +01:00
configs x86/kbuild: Enable CONFIG_KALLSYMS_ALL=y in the defconfigs 2022-01-27 11:04:56 +01:00
crypto crypto: x86/aesni - don't require alignment of data 2022-01-27 11:02:51 +01:00
entry x86/xen: Add xenpv_restore_regs_and_return_to_usermode() 2021-12-08 09:04:54 +01:00
events perf/x86/intel: Don't extend the pseudo-encoding to GP counters 2022-04-13 20:59:23 +02:00
hyperv x86/hyperv: Properly deal with empty cpumasks in hyperv_flush_tlb_multi() 2022-03-08 19:12:36 +01:00
ia32 binfmt: remove in-tree usage of MAP_DENYWRITE 2021-09-03 18:42:01 +02:00
include stat: fix inconsistency between struct stat and struct compat_stat 2022-04-27 14:38:57 +02:00
kernel gup: Turn fault_in_pages_{readable,writeable} into fault_in_{readable,writeable} 2022-05-01 17:22:28 +02:00
kvm KVM: SVM: Flush when freeing encrypted pages even on SME_COHERENT CPUs 2022-04-27 14:39:00 +02:00
lib x86: __memcpy_flushcache: fix wrong alignment if size > 2^32 2022-05-09 09:14:40 +02:00
math-emu
mm x86/mm/tlb: Revert retpoline avoidance approach 2022-04-13 20:59:23 +02:00
net bpf: Fix extable address check. 2021-12-22 09:32:50 +01:00
pci x86/pci/xen: Disable PCI/MSI[-X] masking for XEN_HVM guests 2022-05-09 09:14:31 +02:00
platform x86/sme: Explicitly map new EFI memmap table as encrypted 2021-12-14 10:57:08 +01:00
power x86/speculation: Restore speculation related MSRs during S3 resume 2022-04-13 20:59:22 +02:00
purgatory kernel.h: split out panic and oops helpers 2021-07-01 11:06:04 -07:00
ras
realmode x86/mm: Flush global TLB when switching to trampoline page-table 2022-01-27 11:04:35 +01:00
tools - Remove cc-option checks which are old and already supported by the 2021-08-30 13:27:16 -07:00
um um: registers: Rename function names to avoid conflicts and build problems 2022-01-27 11:04:48 +01:00
video
xen xen: delay xen_hvm_init_time_ops() if kdump is boot on vcpu>=32 2022-04-13 20:59:12 +02:00
.gitignore
Kbuild
Kconfig x86/Kconfig: Do not allow CONFIG_X86_X32_ABI=y with llvm-objcopy 2022-04-13 20:59:13 +02:00
Kconfig.assembler
Kconfig.cpu
Kconfig.debug tracing: Refactor TRACE_IRQFLAGS_SUPPORT in Kconfig 2021-08-16 11:37:21 -04:00
Makefile Kbuild updates for v5.15 2021-09-03 15:33:47 -07:00
Makefile.um
Makefile_32.cpu x86/build: Do not add -falign flags unconditionally for clang 2021-09-19 10:35:53 +09:00