lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Fri,  9 Sep 2022 17:07:55 -0300
From:   "Guilherme G. Piccoli" <gpiccoli@...lia.com>
To:     linux-efi@...r.kernel.org, linux-kernel@...r.kernel.org
Cc:     kernel-dev@...lia.com, kernel@...ccoli.net,
        "Guilherme G. Piccoli" <gpiccoli@...lia.com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Ard Biesheuvel <ardb@...nel.org>,
        David Gow <davidgow@...gle.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Julius Werner <jwerner@...omium.org>,
        Petr Mladek <pmladek@...e.com>,
        Evan Green <evgreen@...omium.org>
Subject: [PATCH V4] firmware: google: Test spinlock on panic path to avoid lockups

Currently the gsmi driver registers a panic notifier as well as
reboot and die notifiers. The callbacks registered are called in
atomic and very limited context - for instance, panic disables
preemption and local IRQs, also all secondary CPUs (not executing
the panic path) are shutdown.

With that said, taking a spinlock in this scenario is a dangerous
invitation for lockup scenarios. So, fix that by checking if the
spinlock is free to acquire in the panic notifier callback - if not,
bail-out and avoid a potential hang.

Fixes: 74c5b31c6618 ("driver: Google EFI SMI")
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: Ard Biesheuvel <ardb@...nel.org>
Cc: David Gow <davidgow@...gle.com>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: Julius Werner <jwerner@...omium.org>
Cc: Petr Mladek <pmladek@...e.com>
Reviewed-by: Evan Green <evgreen@...omium.org>
Signed-off-by: Guilherme G. Piccoli <gpiccoli@...lia.com>
---


Hey folks, new version - V3 available at [0].

@Greg, I think the panic situation is well-described in the commit
message so I didn't rework that, lemme know if you want to add
something to the text.

@Evan, I kept your review tag even with the comment change, based on
the V3 discussion. Lemme know if you want it removed in case you
disagree with something!

V4:
* Reworked comment (thanks Andrew, for the suggestion!);
* Rebased against 6.0-rc4;
* Included more CCs (Andrew, Petr).

[0] https://lore.kernel.org/linux-kernel/20220819155059.451674-1-gpiccoli@igalia.com/


 drivers/firmware/google/gsmi.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/firmware/google/gsmi.c b/drivers/firmware/google/gsmi.c
index adaa492c3d2d..4e2575dfeb90 100644
--- a/drivers/firmware/google/gsmi.c
+++ b/drivers/firmware/google/gsmi.c
@@ -681,6 +681,15 @@ static struct notifier_block gsmi_die_notifier = {
 static int gsmi_panic_callback(struct notifier_block *nb,
 			       unsigned long reason, void *arg)
 {
+
+	/*
+	 * Panic callbacks are executed with all other CPUs stopped,
+	 * so we must not attempt to spin waiting for gsmi_dev.lock
+	 * to be released.
+	 */
+	if (spin_is_locked(&gsmi_dev.lock))
+		return NOTIFY_DONE;
+
 	gsmi_shutdown_reason(GSMI_SHUTDOWN_PANIC);
 	return NOTIFY_DONE;
 }
-- 
2.37.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ