mirror-linux/arch/x86/kernel/cpu/mce
Borislav Petkov (AMD) 3ddf944b32 x86/mce: Make sure to grab mce_sysfs_mutex in set_bank()
Modifying a MCA bank's MCA_CTL bits which control which error types to
be reported is done over

  /sys/devices/system/machinecheck/
  ├── machinecheck0
  │   ├── bank0
  │   ├── bank1
  │   ├── bank10
  │   ├── bank11
  ...

sysfs nodes by writing the new bit mask of events to enable.

When the write is accepted, the kernel deletes all current timers and
reinits all banks.

Doing that in parallel can lead to initializing a timer which is already
armed and in the timer wheel, i.e., in use already:

  ODEBUG: init active (active state 0) object: ffff888063a28000 object
  type: timer_list hint: mce_timer_fn+0x0/0x240 arch/x86/kernel/cpu/mce/core.c:2642
  WARNING: CPU: 0 PID: 8120 at lib/debugobjects.c:514
  debug_print_object+0x1a0/0x2a0 lib/debugobjects.c:514

Fix that by grabbing the sysfs mutex as the rest of the MCA sysfs code
does.

Reported by: Yue Sun <samsun1006219@gmail.com>
Reported by: xingwei lee <xrivendell7@gmail.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Cc: <stable@kernel.org>
Link: https://lore.kernel.org/r/CAEkJfYNiENwQY8yV1LYJ9LjJs%2Bx_-PqMv98gKig55=2vbzffRw@mail.gmail.com
2024-04-04 17:25:15 +02:00
..
Makefile thermal: Move therm_throt there from x86/mce 2021-02-08 11:43:20 +01:00
amd.c x86/cpu/amd: Provide a separate accessor for Node ID 2024-02-15 22:07:37 +01:00
apei.c x86/cpu: Move phys_proc_id into topology info 2023-10-10 14:38:17 +02:00
core.c x86/mce: Make sure to grab mce_sysfs_mutex in set_bank() 2024-04-04 17:25:15 +02:00
dev-mcelog.c x86/mce/dev-mcelog: use strscpy() to instead of strncpy() 2023-01-07 11:47:35 +01:00
genpool.c
inject.c x86/cpu/topology: Get rid of cpuinfo::x86_max_cores 2024-02-16 15:51:32 +01:00
intel.c x86/mce: Handle Intel threshold interrupt storms 2023-12-15 14:53:42 +01:00
internal.h x86/mce: Handle Intel threshold interrupt storms 2023-12-15 14:53:42 +01:00
p5.c x86/mce: Get rid of machine_check_vector 2021-09-23 11:15:49 +02:00
severity.c x86/mce: Use severity table to handle uncorrected errors in kernel 2022-10-31 17:01:19 +01:00
threshold.c x86/mce: Handle Intel threshold interrupt storms 2023-12-15 14:53:42 +01:00
winchip.c x86/mce: Get rid of machine_check_vector 2021-09-23 11:15:49 +02:00