From: Ahmed Ehab <bottaawesome633@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>, Will Deacon <will@kernel.org>,
Waiman Long <longman@redhat.com>,
Boqun Feng <boqun.feng@gmail.com>,
linux-ext4@vger.kernel.org, syzkaller@googlegroups.com
Subject: [PATCH v6 2/2] locking/lockdep: Test no new string literal is created in lockdep_set_subclass()
Date: Sun, 25 Aug 2024 01:10:31 +0300 [thread overview]
Message-ID: <20240824221031.7751-2-bottaawesome633@gmail.com> (raw)
In-Reply-To: <20240824221031.7751-1-bottaawesome633@gmail.com>
Add a test case to ensure that no new name string literal will be
created in lockdep_set_subclass(), otherwise a warning will be triggered
in look_up_lock_class(). Add this to catch the problem in the future.
Signed-off-by: Ahmed Ehab <bottaawesome633@gmail.com>
---
v5->v6:
- Changed the subject and changelog to be in imperative format
lib/locking-selftest.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/lib/locking-selftest.c b/lib/locking-selftest.c
index 6f6a5fc85b42..2b4650bdf833 100644
--- a/lib/locking-selftest.c
+++ b/lib/locking-selftest.c
@@ -2710,6 +2710,32 @@ static void local_lock_3B(void)
}
+static void lock_class_subclass_X1(void)
+{
+ const char *name_before_setting_subclass = rwsem_X1.dep_map.name;
+ const char *name_after_setting_subclass;
+
+ lockdep_set_subclass(&rwsem_X1, 1);
+ name_after_setting_subclass = rwsem_X1.dep_map.name;
+ DEBUG_LOCKS_WARN_ON(name_before_setting_subclass != name_after_setting_subclass);
+}
+
+/*
+ * 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");
+
+ print_testname("lock class and subclass same name");
+ dotest(lock_class_subclass_X1, SUCCESS, LOCKTYPE_RWSEM);
+ pr_cont("\n");
+}
+
static void local_lock_tests(void)
{
printk(" --------------------------------------------------------------------------\n");
@@ -2920,6 +2946,8 @@ void locking_selftest(void)
dotest(hardirq_deadlock_softirq_not_deadlock, FAILURE, LOCKTYPE_SPECIAL);
pr_cont("\n");
+ class_subclass_X1_name_test();
+
if (unexpected_testcase_failures) {
printk("-----------------------------------------------------------------\n");
debug_locks = 0;
--
2.45.2
next prev parent reply other threads:[~2024-08-24 19:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-24 22:10 [PATCH v5 1/2] locking/lockdep: Avoid creating new name string literals in lockdep_set_subclass() Ahmed Ehab
2024-08-24 22:10 ` Ahmed Ehab [this message]
2024-08-26 22:07 ` [PATCH v6 2/2] locking/lockdep: Test no new string literal is created " kernel test robot
[not found] ` <CA+6bSauLj9MBs_HRP6Yt9qXVs4eO30cpvU00u=uj7sG7S8fHmQ@mail.gmail.com>
2024-08-27 18:00 ` Boqun Feng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240824221031.7751-2-bottaawesome633@gmail.com \
--to=bottaawesome633@gmail.com \
--cc=boqun.feng@gmail.com \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=longman@redhat.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=syzkaller@googlegroups.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox