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>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1399941714-20145-1-git-send-email-dbasehore@chromium.org>
Date:	Mon, 12 May 2014 17:41:54 -0700
From:	Derek Basehore <dbasehore@...omium.org>
To:	linux-kernel@...r.kernel.org
Cc:	Andrew Morton <akpm@...ux-foundation.org>,
	Joe Perches <joe@...ches.com>, Petr Mladek <pmladek@...e.cz>,
	Arun KS <arunks.linux@...il.com>,
	Kees Cook <keescook@...omium.org>,
	Sonny Rao <sonnyrao@...omium.org>,
	Derek Basehore <dbasehore@...omium.org>
Subject: [PATCH] Fix lockup on panic with lockdep

If we don't call mutex_acquire at the beginning of console_unblank, we can run
into a lockup on the logbuf_lock between console_unlock and printk during panic.
What happens in console_unlock is:

-locks logbuf_lock
-calls mutex_release
 -which calls printk
  -which locks logbuf_lock

This fixes the problem by calling console_trylock (which calls mutex_acquire)
instead of directly accessing the semaphore in console_unblank and moves the
mutex_release to after we unlock logbuf_lock in console_unlock (interrupts are
still disabled).

Signed-off-by: Derek Basehore <dbasehore@...omium.org>
---
 kernel/printk/printk.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 7228258..c599ab5 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -2084,7 +2084,6 @@ skip:
 		local_irq_restore(flags);
 	}
 	console_locked = 0;
-	mutex_release(&console_lock_dep_map, 1, _RET_IP_);
 
 	/* Release the exclusive_console once it is used */
 	if (unlikely(exclusive_console))
@@ -2092,6 +2091,7 @@ skip:
 
 	raw_spin_unlock(&logbuf_lock);
 
+	mutex_release(&console_lock_dep_map, 1, _RET_IP_);
 	up(&console_sem);
 
 	/*
@@ -2137,7 +2137,7 @@ void console_unblank(void)
 	 * oops_in_progress is set to 1..
 	 */
 	if (oops_in_progress) {
-		if (down_trylock(&console_sem) != 0)
+		if (!console_trylock())
 			return;
 	} else
 		console_lock();
-- 
1.9.1.423.g4596e3a

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ