[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240715063447.391668-2-bottaawesome633@gmail.com>
Date: Mon, 15 Jul 2024 09:34:47 +0300
From: botta633 <bottaawesome633@...il.com>
To: linux-kernel@...r.kernel.org
Cc: Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Will Deacon <will@...nel.org>,
Waiman Long <longman@...hat.com>,
Boqun Feng <boqun.feng@...il.com>,
linux-ext4@...r.kernel.org,
syzkaller@...glegroups.com,
Ahmed Ehab <bottaawesome633@...il.com>,
syzbot+7f4a6f7f7051474e40ad@...kaller.appspotmail.com,
stable@...r.kernel.org
Subject: [PATCH v4 2/2] locking/lockdep: Testing lock class and subclass got the same name pointer
From: Ahmed Ehab <bottaawesome633@...il.com>
Checking if the lockdep_map->name will change when setting the subclass.
It shouldn't change so that the lock class and subclass will have the same
name
Reported-by: <syzbot+7f4a6f7f7051474e40ad@...kaller.appspotmail.com>
Fixes: de8f5e4f2dc1f ("lockdep: Introduce wait-type checks")
Cc: <stable@...r.kernel.org>
Signed-off-by: Ahmed Ehab <bottaawesome633@...il.com>
---
lib/locking-selftest.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/lib/locking-selftest.c b/lib/locking-selftest.c
index 6f6a5fc85b42..aeed613799ca 100644
--- a/lib/locking-selftest.c
+++ b/lib/locking-selftest.c
@@ -2710,6 +2710,25 @@ static void local_lock_3B(void)
}
+ /**
+ * after setting the subclass the lockdep_map.name changes
+ * if we initialize a new string literal for the subclass
+ * we will have a new name pointer
+ */
+static void class_subclass_X1_name_test(void)
+{
+ printk(" --------------------------------------------------------------------------\n");
+ printk(" | class and subclass name test|\n");
+ printk(" ---------------------\n");
+ const char *name_before_setting_subclass = rwsem_X1.dep_map.name;
+ const char *name_after_setting_subclass;
+
+ WARN_ON(!rwsem_X1.dep_map.name);
+ lockdep_set_subclass(&rwsem_X1, 1);
+ name_after_setting_subclass = rwsem_X1.dep_map.name;
+ WARN_ON(name_before_setting_subclass != name_after_setting_subclass);
+}
+
static void local_lock_tests(void)
{
printk(" --------------------------------------------------------------------------\n");
@@ -2916,6 +2935,8 @@ void locking_selftest(void)
local_lock_tests();
+ class_subclass_X1_name_test();
+
print_testname("hardirq_unsafe_softirq_safe");
dotest(hardirq_deadlock_softirq_not_deadlock, FAILURE, LOCKTYPE_SPECIAL);
pr_cont("\n");
--
2.45.2
Powered by blists - more mailing lists