]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.19/locking-lockdep-add-debug_locks-check-in-__lock_downgrade.patch
Linux 4.14.109
[thirdparty/kernel/stable-queue.git] / queue-4.19 / locking-lockdep-add-debug_locks-check-in-__lock_downgrade.patch
1 From 71492580571467fb7177aade19c18ce7486267f5 Mon Sep 17 00:00:00 2001
2 From: Waiman Long <longman@redhat.com>
3 Date: Wed, 9 Jan 2019 23:03:25 -0500
4 Subject: locking/lockdep: Add debug_locks check in __lock_downgrade()
5
6 From: Waiman Long <longman@redhat.com>
7
8 commit 71492580571467fb7177aade19c18ce7486267f5 upstream.
9
10 Tetsuo Handa had reported he saw an incorrect "downgrading a read lock"
11 warning right after a previous lockdep warning. It is likely that the
12 previous warning turned off lock debugging causing the lockdep to have
13 inconsistency states leading to the lock downgrade warning.
14
15 Fix that by add a check for debug_locks at the beginning of
16 __lock_downgrade().
17
18 Debugged-by: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
19 Reported-by: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
20 Reported-by: syzbot+53383ae265fb161ef488@syzkaller.appspotmail.com
21 Signed-off-by: Waiman Long <longman@redhat.com>
22 Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
23 Cc: Andrew Morton <akpm@linux-foundation.org>
24 Cc: Linus Torvalds <torvalds@linux-foundation.org>
25 Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
26 Cc: Peter Zijlstra <peterz@infradead.org>
27 Cc: Thomas Gleixner <tglx@linutronix.de>
28 Cc: Will Deacon <will.deacon@arm.com>
29 Link: https://lkml.kernel.org/r/1547093005-26085-1-git-send-email-longman@redhat.com
30 Signed-off-by: Ingo Molnar <mingo@kernel.org>
31 Signed-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 @@ -3567,6 +3567,9 @@ __lock_set_class(struct lockdep_map *loc
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,