android_kernel_oneplus_msm8998/arch/x86/kernel/cpu/mcheck
Seunghun Han e882c0baab x86/MCE: Serialize sysfs changes
commit b3b7c4795ccab5be71f080774c45bbbcc75c2aaf upstream.

The check_interval file in

  /sys/devices/system/machinecheck/machinecheck<cpu number>

directory is a global timer value for MCE polling. If it is changed by one
CPU, mce_restart() broadcasts the event to other CPUs to delete and restart
the MCE polling timer and __mcheck_cpu_init_timer() reinitializes the
mce_timer variable.

If more than one CPU writes a specific value to the check_interval file
concurrently, mce_timer is not protected from such concurrent accesses and
all kinds of explosions happen. Since only root can write to those sysfs
variables, the issue is not a big deal security-wise.

However, concurrent writes to these configuration variables is void of
reason so the proper thing to do is to serialize the access with a mutex.

Boris:

 - Make store_int_with_restart() use device_store_ulong() to filter out
   negative intervals
 - Limit min interval to 1 second
 - Correct locking
 - Massage commit message

Signed-off-by: Seunghun Han <kkamagui@gmail.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: linux-edac <linux-edac@vger.kernel.org>
Cc: stable@vger.kernel.org
Link: http://lkml.kernel.org/r/20180302202706.9434-1-kkamagui@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-03-18 11:17:50 +01:00
..
Makefile x86/mce: Provide a lockless memory pool to save error records 2015-08-13 10:12:50 +02:00
mce-apei.c x86/mce: Avoid potential deadlock due to printk() in MCE context 2015-08-13 10:12:51 +02:00
mce-genpool.c x86/mce: Avoid using object after free in genpool 2016-05-04 14:48:40 -07:00
mce-inject.c x86/ras/inject: Make it depend on X86_LOCAL_APIC=y 2018-02-25 11:03:42 +01:00
mce-internal.h x86/mce: Add a wrapper around mce_log() for injection 2015-08-13 10:12:53 +02:00
mce-severity.c x86/mce/severity: Fix warning about indented braces 2015-04-03 15:20:38 +02:00
mce.c x86/MCE: Serialize sysfs changes 2018-03-18 11:17:50 +01:00
mce_amd.c x86/mce/AMD: Make the init code more robust 2017-08-06 19:19:44 -07:00
mce_intel.c x86/mce: Reenable CMCI banks when swiching back to interrupt mode 2015-08-13 10:12:52 +02:00
p5.c x86/entry: Remove exception_enter() from most trap handlers 2015-07-07 10:59:09 +02:00
therm_throt.c ACPI / processor: Request native thermal interrupt handling via _OSC 2016-05-11 11:21:26 +02:00
threshold.c asmlinkage, x86: Add explicit __visible to arch/x86/* 2014-05-05 16:07:44 -07:00
winchip.c x86/entry: Remove exception_enter() from most trap handlers 2015-07-07 10:59:09 +02:00