lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20240714052640.115476-1-bottaawesome633@gmail.com>
Date: Sun, 14 Jul 2024 08:26:40 +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 v2 2/2] ext4: 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: fd5e3f5fe27
Cc: <stable@...r.kernel.org>
Signed-off-by: botta633 <bottaawesome633@...il.com>
---
 lib/locking-selftest.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/lib/locking-selftest.c b/lib/locking-selftest.c
index 6f6a5fc85b42..1d7885205f36 100644
--- a/lib/locking-selftest.c
+++ b/lib/locking-selftest.c
@@ -2710,12 +2710,24 @@ static void local_lock_3B(void)
 
 }
 
+static void class_subclass_X1_name(void)
+{
+	const char *name_before_subclass = rwsem_X1.dep_map.name;
+	const char *name_after_subclass;
+
+	WARN_ON(!rwsem_X1.dep_map.name);
+	lockdep_set_subclass(&rwsem_X1, 1);
+	WARN_ON(name_before_subclass != name_after_subclass);
+}
+
 static void local_lock_tests(void)
 {
 	printk("  --------------------------------------------------------------------------\n");
 	printk("  | local_lock tests |\n");
 	printk("  ---------------------\n");
 
+	init_class_X(&lock_X1, &rwlock_X1, &mutex_X1, &rwsem_X1);
+
 	print_testname("local_lock inversion  2");
 	dotest(local_lock_2, SUCCESS, LOCKTYPE_LL);
 	pr_cont("\n");
@@ -2727,6 +2739,10 @@ static void local_lock_tests(void)
 	print_testname("local_lock inversion 3B");
 	dotest(local_lock_3B, FAILURE, LOCKTYPE_LL);
 	pr_cont("\n");
+
+	print_testname("Class and subclass");
+	dotest(class_subclass_X1_name, SUCCESS, LOCKTYPE_RWSEM);
+	pr_cont("\n");
 }
 
 static void hardirq_deadlock_softirq_not_deadlock(void)
-- 
2.45.2


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ