From: "Levin, Alexander (Sasha Levin)" <alexander.levin@verizon.com>
To: "gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: [GIT PULL for-3.18 01/13] locking/lockdep: Add nest_lock integrity test
Date: Wed, 11 Oct 2017 00:45:52 +0000 [thread overview]
Message-ID: <20171011004547.8116-2-alexander.levin@verizon.com> (raw)
In-Reply-To: <20171011004547.8116-1-alexander.levin@verizon.com>
From: Peter Zijlstra <peterz@infradead.org>
[ Upstream commit 7fb4a2cea6b18dab56d609530d077f168169ed6b ]
Boqun reported that hlock->references can overflow. Add a debug test
for that to generate a clear error when this happens.
Without this, lockdep is likely to report a mysterious failure on
unlock.
Reported-by: Boqun Feng <boqun.feng@gmail.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Nicolai Hähnle <Nicolai.Haehnle@amd.com>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
kernel/locking/lockdep.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index 88d0d4420ad2..3467618cc0ea 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -3107,10 +3107,17 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
if (depth) {
hlock = curr->held_locks + depth - 1;
if (hlock->class_idx == class_idx && nest_lock) {
- if (hlock->references)
+ if (hlock->references) {
+ /*
+ * Check: unsigned int references:12, overflow.
+ */
+ if (DEBUG_LOCKS_WARN_ON(hlock->references == (1 << 12)-1))
+ return 0;
+
hlock->references++;
- else
+ } else {
hlock->references = 2;
+ }
return 1;
}
--
2.11.0
next prev parent reply other threads:[~2017-10-11 0:47 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-11 0:45 [GIT PULL for-3.18 00/13] Commits for v3.18 LTS Levin, Alexander (Sasha Levin)
2017-10-11 0:45 ` Levin, Alexander (Sasha Levin) [this message]
2017-10-11 0:45 ` [GIT PULL for-3.18 02/13] watchdog: kempld: fix gcc-4.3 build Levin, Alexander (Sasha Levin)
2017-10-11 0:45 ` [GIT PULL for-3.18 03/13] irqchip/crossbar: Fix incorrect type of local variables Levin, Alexander (Sasha Levin)
2017-10-11 0:45 ` [GIT PULL for-3.18 05/13] iio: adc: xilinx: Fix error handling Levin, Alexander (Sasha Levin)
2017-10-11 0:45 ` [GIT PULL for-3.18 04/13] netfilter: nf_ct_expect: Change __nf_ct_expect_check() return value Levin, Alexander (Sasha Levin)
2017-10-11 0:45 ` [GIT PULL for-3.18 06/13] Btrfs: send, fix failure to rename top level inode due to name collision Levin, Alexander (Sasha Levin)
2017-10-11 0:45 ` [GIT PULL for-3.18 08/13] crypto: xts - Add ECB dependency Levin, Alexander (Sasha Levin)
2017-10-11 0:45 ` [GIT PULL for-3.18 07/13] net/mlx4_core: Fix VF overwrite of module param which disables DMFS on new probed PFs Levin, Alexander (Sasha Levin)
2017-10-11 0:45 ` [GIT PULL for-3.18 09/13] ocfs2/dlmglue: prepare tracking logic to avoid recursive cluster lock Levin, Alexander (Sasha Levin)
2017-10-11 0:45 ` [GIT PULL for-3.18 11/13] uapi: fix linux/rds.h userspace compilation errors Levin, Alexander (Sasha Levin)
2017-10-11 0:45 ` [GIT PULL for-3.18 10/13] scsi: scsi_dh_emc: return success in clariion_std_inquiry() Levin, Alexander (Sasha Levin)
2017-10-11 0:45 ` [GIT PULL for-3.18 12/13] uapi: fix linux/mroute6.h userspace compilation errors Levin, Alexander (Sasha Levin)
2017-10-11 0:45 ` [GIT PULL for-3.18 13/13] target/iscsi: Fix unsolicited data seq_end_offset calculation Levin, Alexander (Sasha Levin)
2017-10-19 13:27 ` [GIT PULL for-3.18 00/13] Commits for v3.18 LTS gregkh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171011004547.8116-2-alexander.levin@verizon.com \
--to=alexander.levin@verizon.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®