All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH review for 4.4 01/26] locking/lockdep: Add nest_lock integrity test
@ 2017-09-25  1:13 Levin, Alexander (Sasha Levin)
  2017-09-25  1:13 ` [PATCH review for 4.4 03/26] irqchip/crossbar: Fix incorrect type of local variables Levin, Alexander (Sasha Levin)
                   ` (24 more replies)
  0 siblings, 25 replies; 28+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-09-25  1:13 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Peter Zijlstra, Andrew Morton, Chris Wilson, Linus Torvalds,
	Nicolai Hähnle, Paul E . McKenney, Thomas Gleixner,
	Ingo Molnar, Levin, Alexander (Sasha Levin)

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 60ace56618f6..0e2c4911ba61 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -3128,10 +3128,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

^ permalink raw reply related	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2017-09-25 14:35 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-25  1:13 [PATCH review for 4.4 01/26] locking/lockdep: Add nest_lock integrity test Levin, Alexander (Sasha Levin)
2017-09-25  1:13 ` [PATCH review for 4.4 03/26] irqchip/crossbar: Fix incorrect type of local variables Levin, Alexander (Sasha Levin)
2017-09-25  1:13 ` [PATCH review for 4.4 02/26] watchdog: kempld: fix gcc-4.3 build Levin, Alexander (Sasha Levin)
2017-09-25  1:13 ` [PATCH review for 4.4 04/26] mac80211_hwsim: check HWSIM_ATTR_RADIO_NAME length Levin, Alexander (Sasha Levin)
2017-09-25  1:13 ` [PATCH review for 4.4 05/26] mac80211: fix power saving clients handling in iwlwifi Levin, Alexander (Sasha Levin)
2017-09-25  1:13 ` [PATCH review for 4.4 06/26] net/mlx4_en: fix overflow in mlx4_en_init_timestamp() Levin, Alexander (Sasha Levin)
2017-09-25  1:13 ` [PATCH review for 4.4 07/26] netfilter: nf_ct_expect: Change __nf_ct_expect_check() return value Levin, Alexander (Sasha Levin)
2017-09-25  1:13 ` [PATCH review for 4.4 09/26] Btrfs: send, fix failure to rename top level inode due to name collision Levin, Alexander (Sasha Levin)
2017-09-25  1:13 ` [PATCH review for 4.4 08/26] iio: adc: xilinx: Fix error handling Levin, Alexander (Sasha Levin)
2017-09-25  1:13 ` [PATCH review for 4.4 11/26] md/linear: shutup lockdep warnning Levin, Alexander (Sasha Levin)
2017-09-25  1:13 ` [PATCH review for 4.4 10/26] f2fs: do not wait for writeback in write_begin Levin, Alexander (Sasha Levin)
2017-09-25  1:13 ` [PATCH review for 4.4 12/26] sparc64: Migrate hvcons irq to panicked cpu Levin, Alexander (Sasha Levin)
2017-09-25  1:13 ` [PATCH review for 4.4 13/26] net/mlx4_core: Fix VF overwrite of module param which disables DMFS on new probed PFs Levin, Alexander (Sasha Levin)
2017-09-25  1:13 ` [PATCH review for 4.4 14/26] crypto: xts - Add ECB dependency Levin, Alexander (Sasha Levin)
2017-09-25  1:13 ` [PATCH review for 4.4 15/26] ocfs2/dlmglue: prepare tracking logic to avoid recursive cluster lock Levin, Alexander (Sasha Levin)
2017-09-25  1:13 ` [PATCH review for 4.4 18/26] net: mvpp2: release reference to txq_cpu[] entry after unmapping Levin, Alexander (Sasha Levin)
2017-09-25  1:13 ` [PATCH review for 4.4 16/26] slub: do not merge cache if slub_debug contains a never-merge flag Levin, Alexander (Sasha Levin)
2017-09-25  1:13 ` [PATCH review for 4.4 17/26] scsi: scsi_dh_emc: return success in clariion_std_inquiry() Levin, Alexander (Sasha Levin)
2017-09-25  1:13 ` [PATCH review for 4.4 19/26] i2c: at91: ensure state is restored after suspending Levin, Alexander (Sasha Levin)
2017-09-25  7:22   ` Alexandre Belloni
2017-09-25 14:33     ` Levin, Alexander (Sasha Levin)
2017-09-25  1:13 ` [PATCH review for 4.4 20/26] ceph: clean up unsafe d_parent accesses in build_dentry_path Levin, Alexander (Sasha Levin)
2017-09-25  1:13 ` [PATCH review for 4.4 23/26] target/iscsi: Fix unsolicited data seq_end_offset calculation Levin, Alexander (Sasha Levin)
2017-09-25  1:13 ` [PATCH review for 4.4 21/26] uapi: fix linux/rds.h userspace compilation errors Levin, Alexander (Sasha Levin)
2017-09-25  1:13 ` [PATCH review for 4.4 22/26] uapi: fix linux/mroute6.h " Levin, Alexander (Sasha Levin)
2017-09-25  1:13 ` [PATCH review for 4.4 26/26] cpufreq: CPPC: add ACPI_PROCESSOR dependency Levin, Alexander (Sasha Levin)
2017-09-25  1:13 ` [PATCH review for 4.4 25/26] genirq: Clarify logic calculating bogus irqreturn_t values Levin, Alexander (Sasha Levin)
2017-09-25  1:13 ` [PATCH review for 4.4 24/26] nfsd/callback: Cleanup callback cred on shutdown Levin, Alexander (Sasha Levin)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.