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: <1461641797-9368-1-git-send-email-yang.shi@linaro.org>
Date:	Mon, 25 Apr 2016 20:36:37 -0700
From:	Yang Shi <yang.shi@...aro.org>
To:	peterz@...radead.org, mingo@...hat.com
Cc:	linux-kernel@...r.kernel.org, linaro-kernel@...ts.linaro.org,
	yang.shi@...aro.org
Subject: [PATCH] panic: lockdep: correct lock debugging state check

When kernel oops happens, lock debugging is turned off by debug_locks_off()
in oops_enter() via calling __debug_locks_off() which set debug_locks to 0
via xchg(). But, calling to __debug_locks_off() to check lock debugging state
in add_taint() called by oops_end() will always return false since xchg()
returns the old value of debug_locks which is cleared in oops_enter() already.

This prevents add_taint() from printing out lock debugging disable information
although LOCKDEP_NOW_UNRELIABLE is passed to it.

Check lock debugging state via !debug_locks to fix this. Although
!__debug_locks_off() could do the same thing, it may look confusing.

Before the fix, oops output looks like:
RIP  [<ffffffff8119d2f8>] release_freepages+0x18/0xa0
 RSP <ffff88036173fcf8>
CR2: 0000000000000000
[ end trace 2e96d09e0ba6342f ]

Aftere the fix, it looks like:
RIP  [<ffffffff8119d2f8>] release_freepages+0x18/0xa0
 RSP <ffff88036173fcf8>
CR2: 0000000000000000
Disabling lock debugging due to kernel taint
[ end trace 2e96d09e0ba6342f ]

And, fix a trivial typo in the comment of add_taint().

Signed-off-by: Yang Shi <yang.shi@...aro.org>
---
 kernel/panic.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/panic.c b/kernel/panic.c
index 535c965..859499d 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -346,11 +346,11 @@ unsigned long get_taint(void)
  * @lockdep_ok: whether lock debugging is still OK.
  *
  * If something bad has gone wrong, you'll want @lockdebug_ok = false, but for
- * some notewortht-but-not-corrupting cases, it can be set to true.
+ * some noteworthy-but-not-corrupting cases, it can be set to true.
  */
 void add_taint(unsigned flag, enum lockdep_ok lockdep_ok)
 {
-	if (lockdep_ok == LOCKDEP_NOW_UNRELIABLE && __debug_locks_off())
+	if (lockdep_ok == LOCKDEP_NOW_UNRELIABLE && !debug_locks)
 		pr_warn("Disabling lock debugging due to kernel taint\n");
 
 	set_bit(flag, &tainted_mask);
-- 
2.0.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ