]> git.baikalelectronics.ru Git - kernel.git/commit
x86/mce/amd: Fix kobject lifetime
authorThomas Gleixner <tglx@linutronix.de>
Thu, 13 Feb 2020 18:01:34 +0000 (19:01 +0100)
committerBorislav Petkov <bp@suse.de>
Fri, 14 Feb 2020 08:28:31 +0000 (09:28 +0100)
commitc6d9d161087f1c02fded3f9b4b82bc8e3a4babe9
treead41ff406864889187ef64c3a3e3fb62539e340b
parent040ffe3b32c3855801a20404dce3159e14888291
x86/mce/amd: Fix kobject lifetime

Accessing the MCA thresholding controls in sysfs concurrently with CPU
hotplug can lead to a couple of KASAN-reported issues:

  BUG: KASAN: use-after-free in sysfs_file_ops+0x155/0x180
  Read of size 8 at addr ffff888367578940 by task grep/4019

and

  BUG: KASAN: use-after-free in show_error_count+0x15c/0x180
  Read of size 2 at addr ffff888368a05514 by task grep/4454

for example. Both result from the fact that the threshold block
creation/teardown code frees the descriptor memory itself instead of
defining proper ->release function and leaving it to the driver core to
take care of that, after all sysfs accesses have completed.

Do that and get rid of the custom freeing code, fixing the above UAFs in
the process.

  [ bp: write commit message. ]

Fixes: 29a19644469e ("[PATCH] x86_64: mce_amd support for family 0x10 processors")
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: <stable@vger.kernel.org>
Link: https://lkml.kernel.org/r/20200214082801.13836-1-bp@alien8.de
arch/x86/kernel/cpu/mce/amd.c