tmp_suning_uos_patched/arch/x86
Zhang Zixun 595e1ec55b x86/mce/inject: Avoid out-of-bounds write when setting flags
[ Upstream commit de768416b203ac84e02a757b782a32efb388476f ]

A contrived zero-length write, for example, by using write(2):

  ...
  ret = write(fd, str, 0);
  ...

to the "flags" file causes:

  BUG: KASAN: stack-out-of-bounds in flags_write
  Write of size 1 at addr ffff888019be7ddf by task writefile/3787

  CPU: 4 PID: 3787 Comm: writefile Not tainted 5.16.0-rc7+ #12
  Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.14.0-2 04/01/2014

due to accessing buf one char before its start.

Prevent such out-of-bounds access.

  [ bp: Productize into a proper patch. Link below is the next best
    thing because the original mail didn't get archived on lore. ]

Fixes: 0451d14d05 ("EDAC, mce_amd_inj: Modify flags attribute to use string arguments")
Signed-off-by: Zhang Zixun <zhang133010@icloud.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lore.kernel.org/linux-edac/YcnePfF1OOqoQwrX@zn.tnic/
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-01-27 10:54:00 +01:00
..
boot x86/boot/compressed: Move CLANG_FLAGS to beginning of KBUILD_CFLAGS 2022-01-27 10:54:00 +01:00
configs
crypto crypto: x86/curve25519 - fix cpu feature checking logic in mod_exit 2021-07-14 16:56:06 +02:00
entry x86/entry: Add a fence for kernel entry SWAPGS in paranoid_entry() 2021-12-08 09:03:27 +01:00
events perf: Protect perf_guest_cbs with RCU 2022-01-20 09:17:50 +01:00
hyperv x86/hyperv: Fix NULL deref in set_hv_tscchange_cb() if Hyper-V setup fails 2021-11-26 10:39:19 +01:00
ia32
include x86/uaccess: Move variable into switch case statement 2022-01-27 10:53:55 +01:00
kernel x86/mce/inject: Avoid out-of-bounds write when setting flags 2022-01-27 10:54:00 +01:00
kvm KVM: VMX: switch blocked_vcpu_on_cpu_lock to raw spinlock 2022-01-27 10:53:40 +01:00
lib x86/iopl: Fake iopl(3) CLI/STI usage 2021-11-21 13:46:36 +01:00
math-emu
mm x86/sev: Make the #VC exception stacks part of the default stacks storage 2021-11-18 14:04:32 +01:00
net bpf: Handle return value of BPF_PROG_TYPE_STRUCT_OPS prog 2021-10-06 15:55:50 +02:00
oprofile
pci PCI: Add AMD RS690 quirk to enable 64-bit DMA 2021-06-30 08:47:23 -04:00
platform x86/sme: Explicitly map new EFI memmap table as encrypted 2021-12-14 11:32:35 +01:00
power PM: hibernate: x86: Use crc32 instead of md5 for hibernation e820 integrity check 2021-05-14 09:50:21 +02:00
purgatory
ras
realmode x86/64/mm: Map all kernel memory into trampoline_pgd 2021-12-08 09:03:28 +01:00
tools x86/tools: Fix objdump version check again 2021-08-18 08:59:15 +02:00
um
video
xen x86/pv: Switch SWAPGS to ALTERNATIVE 2021-12-08 09:03:27 +01:00
.gitignore
Kbuild
Kconfig x86/sme: Explicitly map new EFI memmap table as encrypted 2021-12-14 11:32:35 +01:00
Kconfig.assembler
Kconfig.cpu
Kconfig.debug
Makefile x86/build: Propagate $(CLANG_FLAGS) to $(REALMODE_FLAGS) 2021-05-11 14:47:18 +02:00
Makefile_32.cpu
Makefile.um