From 60787a00b78b3dcac0aa84adffaccbcb049bd566 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 8 Apr 2024 11:34:23 +0200 Subject: [PATCH] 5.4-stable patches added patches: x86-mce-make-sure-to-grab-mce_sysfs_mutex-in-set_bank.patch --- queue-5.4/series | 1 + ...-to-grab-mce_sysfs_mutex-in-set_bank.patch | 67 +++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 queue-5.4/x86-mce-make-sure-to-grab-mce_sysfs_mutex-in-set_bank.patch diff --git a/queue-5.4/series b/queue-5.4/series index 1f08f097b56..8fed2812e43 100644 --- a/queue-5.4/series +++ b/queue-5.4/series @@ -170,3 +170,4 @@ ata-sata_sx4-fix-pdc20621_get_from_dimm-on-64-bit.patch scsi-mylex-fix-sysfs-buffer-lengths.patch ata-sata_mv-fix-pci-device-id-table-declaration-comp.patch alsa-hda-realtek-update-panasonic-cf-sz6-quirk-to-support-headset-with-microphone.patch +x86-mce-make-sure-to-grab-mce_sysfs_mutex-in-set_bank.patch diff --git a/queue-5.4/x86-mce-make-sure-to-grab-mce_sysfs_mutex-in-set_bank.patch b/queue-5.4/x86-mce-make-sure-to-grab-mce_sysfs_mutex-in-set_bank.patch new file mode 100644 index 00000000000..5ebe8bc00ac --- /dev/null +++ b/queue-5.4/x86-mce-make-sure-to-grab-mce_sysfs_mutex-in-set_bank.patch @@ -0,0 +1,67 @@ +From 3ddf944b32f88741c303f0b21459dbb3872b8bc5 Mon Sep 17 00:00:00 2001 +From: "Borislav Petkov (AMD)" +Date: Wed, 13 Mar 2024 14:48:27 +0100 +Subject: x86/mce: Make sure to grab mce_sysfs_mutex in set_bank() +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Borislav Petkov (AMD) + +commit 3ddf944b32f88741c303f0b21459dbb3872b8bc5 upstream. + +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 +Reported by: xingwei lee +Signed-off-by: Borislav Petkov (AMD) +Cc: +Link: https://lore.kernel.org/r/CAEkJfYNiENwQY8yV1LYJ9LjJs%2Bx_-PqMv98gKig55=2vbzffRw@mail.gmail.com +Signed-off-by: Greg Kroah-Hartman +--- + arch/x86/kernel/cpu/mce/core.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +--- a/arch/x86/kernel/cpu/mce/core.c ++++ b/arch/x86/kernel/cpu/mce/core.c +@@ -2228,12 +2228,14 @@ static ssize_t set_bank(struct device *s + return -EINVAL; + + b = &per_cpu(mce_banks_array, s->id)[bank]; +- + if (!b->init) + return -ENODEV; + + b->ctl = new; ++ ++ mutex_lock(&mce_sysfs_mutex); + mce_restart(); ++ mutex_unlock(&mce_sysfs_mutex); + + return size; + } -- 2.39.5