linux-stable/arch
Zhang Zixun d49992de00 x86/mce/inject: Avoid out-of-bounds write when setting flags
[ Upstream commit de768416b2 ]

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 09:19:35 +01:00
..
alpha
arc
arm ARM: dts: armada-38x: Add generic compatible to UART nodes 2022-01-27 09:19:34 +01:00
arm64 arm64: dts: ti: k3-j721e: Fix the L2 cache sets 2022-01-27 09:19:32 +01:00
c6x
csky
h8300
hexagon
ia64
m68k
microblaze
mips
nds32
nios2
openrisc
parisc
powerpc
riscv
s390 KVM: s390: Clarify SIGP orders versus STOP/RESTART 2022-01-20 09:19:18 +01:00
sh
sparc
um
unicore32
x86 x86/mce/inject: Avoid out-of-bounds write when setting flags 2022-01-27 09:19:35 +01:00
xtensa
.gitignore
Kconfig