]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/5.0.5/locking-lockdep-add-debug_locks-check-in-__lock_downgrade.patch
Linux 5.0.5
[thirdparty/kernel/stable-queue.git] / releases / 5.0.5 / locking-lockdep-add-debug_locks-check-in-__lock_downgrade.patch
CommitLineData
77348cdf
GKH
1From 71492580571467fb7177aade19c18ce7486267f5 Mon Sep 17 00:00:00 2001
2From: Waiman Long <longman@redhat.com>
3Date: Wed, 9 Jan 2019 23:03:25 -0500
4Subject: locking/lockdep: Add debug_locks check in __lock_downgrade()
5
6From: Waiman Long <longman@redhat.com>
7
8commit 71492580571467fb7177aade19c18ce7486267f5 upstream.
9
10Tetsuo Handa had reported he saw an incorrect "downgrading a read lock"
11warning right after a previous lockdep warning. It is likely that the
12previous warning turned off lock debugging causing the lockdep to have
13inconsistency states leading to the lock downgrade warning.
14
15Fix that by add a check for debug_locks at the beginning of
16__lock_downgrade().
17
18Debugged-by: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
19Reported-by: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
20Reported-by: syzbot+53383ae265fb161ef488@syzkaller.appspotmail.com
21Signed-off-by: Waiman Long <longman@redhat.com>
22Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
23Cc: Andrew Morton <akpm@linux-foundation.org>
24Cc: Linus Torvalds <torvalds@linux-foundation.org>
25Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
26Cc: Peter Zijlstra <peterz@infradead.org>
27Cc: Thomas Gleixner <tglx@linutronix.de>
28Cc: Will Deacon <will.deacon@arm.com>
29Link: https://lkml.kernel.org/r/1547093005-26085-1-git-send-email-longman@redhat.com
30Signed-off-by: Ingo Molnar <mingo@kernel.org>
31Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
32
33---
34 kernel/locking/lockdep.c | 3 +++
35 1 file changed, 3 insertions(+)
36
37--- a/kernel/locking/lockdep.c
38+++ b/kernel/locking/lockdep.c
39@@ -3535,6 +3535,9 @@ static int __lock_downgrade(struct lockd
40 unsigned int depth;
41 int i;
42
43+ if (unlikely(!debug_locks))
44+ return 0;
45+
46 depth = curr->lockdep_depth;
47 /*
48 * This function is about (re)setting the class of a held lock,