diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2019-04-14 13:51:06 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2019-04-14 17:05:52 -0400 |
commit | 2f5fb19341883bb6e37da351bc3700489d8506a7 (patch) | |
tree | 7773a842ba67a344b4b4da5aff530404f140571d | |
parent | 40fba00ffa431c8597ca785ea1cfa4d9f6503390 (diff) |
x86/speculation: Prevent deadlock on ssb_state::lock
Mikhail reported a lockdep splat related to the AMD specific ssb_state
lock:
CPU0 CPU1
lock(&st->lock);
local_irq_disable();
lock(&(&sighand->siglock)->rlock);
lock(&st->lock);
<Interrupt>
lock(&(&sighand->siglock)->rlock);
*** DEADLOCK ***
The connection between sighand->siglock and st->lock comes through seccomp,
which takes st->lock while holding sighand->siglock.
Make sure interrupts are disabled when __speculation_ctrl_update() is
invoked via prctl() -> speculation_ctrl_update(). Add a lockdep assert to
catch future offenders.
Fixes: 1f50ddb4f418 ("x86/speculation: Handle HT correctly on AMD")
Reported-by: Mikhail Gavrilov <mikhail.v.gavrilov@gmail.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Mikhail Gavrilov <mikhail.v.gavrilov@gmail.com>
Cc: Thomas Lendacky <thomas.lendacky@amd.com>
Cc: stable@vger.kernel.org
Link: https://lkml.kernel.org/r/alpine.DEB.2.21.1904141948200.4917@nanos.tec.linutronix.de
-rw-r--r-- | arch/x86/kernel/process.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c index 58ac7be52c7a..957eae13b370 100644 --- a/arch/x86/kernel/process.c +++ b/arch/x86/kernel/process.c | |||
@@ -426,6 +426,8 @@ static __always_inline void __speculation_ctrl_update(unsigned long tifp, | |||
426 | u64 msr = x86_spec_ctrl_base; | 426 | u64 msr = x86_spec_ctrl_base; |
427 | bool updmsr = false; | 427 | bool updmsr = false; |
428 | 428 | ||
429 | lockdep_assert_irqs_disabled(); | ||
430 | |||
429 | /* | 431 | /* |
430 | * If TIF_SSBD is different, select the proper mitigation | 432 | * If TIF_SSBD is different, select the proper mitigation |
431 | * method. Note that if SSBD mitigation is disabled or permanentely | 433 | * method. Note that if SSBD mitigation is disabled or permanentely |
@@ -477,10 +479,12 @@ static unsigned long speculation_ctrl_update_tif(struct task_struct *tsk) | |||
477 | 479 | ||
478 | void speculation_ctrl_update(unsigned long tif) | 480 | void speculation_ctrl_update(unsigned long tif) |
479 | { | 481 | { |
482 | unsigned long flags; | ||
483 | |||
480 | /* Forced update. Make sure all relevant TIF flags are different */ | 484 | /* Forced update. Make sure all relevant TIF flags are different */ |
481 | preempt_disable(); | 485 | local_irq_save(flags); |
482 | __speculation_ctrl_update(~tif, tif); | 486 | __speculation_ctrl_update(~tif, tif); |
483 | preempt_enable(); | 487 | local_irq_restore(flags); |
484 | } | 488 | } |
485 | 489 | ||
486 | /* Called from seccomp/prctl update */ | 490 | /* Called from seccomp/prctl update */ |