From: Thorsten Blum <thorsten.blum@linux.dev>
To: Boqun Feng <boqun@kernel.org>
Cc: Waiman Long <longman@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>, Will Deacon <will@kernel.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH RESEND] locking/lockdep: Replace snprintf with strscpy in seq_stats
Date: Tue, 9 Jun 2026 17:22:13 +0200 [thread overview]
Message-ID: <aigvpfqvTlDYDp7r@linux.dev> (raw)
In-Reply-To: <aigbLzT34ddEbSQm@tardis-2.local>
On Tue, Jun 09, 2026 at 06:54:55AM -0700, Boqun Feng wrote:
> On Wed, Mar 18, 2026 at 09:44:49AM -0700, Boqun Feng wrote:
> > On Wed, Mar 18, 2026 at 11:43:49AM -0400, Waiman Long wrote:
> > >
> > > On 3/17/26 8:14 PM, Thorsten Blum wrote:
> > > > Replace snprintf("%s", ...) with the faster and more direct strscpy().
> > > >
> > > > Reviewed-by: Waiman Long <longman@redhat.com>
> > > > Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> > > > ---
> > > > kernel/locking/lockdep_proc.c | 5 +++--
> > > > 1 file changed, 3 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git a/kernel/locking/lockdep_proc.c b/kernel/locking/lockdep_proc.c
> > > > index 1916db9aa46b..e458fa258d05 100644
> > > > --- a/kernel/locking/lockdep_proc.c
> > > > +++ b/kernel/locking/lockdep_proc.c
> > > > @@ -19,6 +19,7 @@
> > > > #include <linux/debug_locks.h>
> > > > #include <linux/vmalloc.h>
> > > > #include <linux/sort.h>
> > > > +#include <linux/string.h>
> > > > #include <linux/uaccess.h>
> > > > #include <asm/div64.h>
> > > > @@ -488,9 +489,9 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
> > > > const char *key_name;
> > > > key_name = __get_key_name(ckey, str);
> > > > - snprintf(name, namelen, "%s", key_name);
> > > > + strscpy(name, key_name, namelen);
> > > > } else {
> > > > - snprintf(name, namelen, "%s", cname);
> > > > + strscpy(name, cname, namelen);
> > > > }
> > > > rcu_read_unlock_sched();
> > > >
> > > Acked-by: Waiman Long <longman@redhat.com>
> > >
> >
> > Queued, thank you both!
> >
>
> I was trying to merge it for v7.2 but sashiko found it out this:
>
> https://sashiko.dev/#/patchset/20260605052331.1628-1-boqun%40kernel.org
>
> Thorsten, could you take a look?
This appears valid, so we should probably drop this patch. I incorrectly
assumed snprintf() also requires the source to be non-NULL for %s.
Handling a failed lookup explicitly could improve this code, but that
requires more work and testing because it would change /proc/lock_stat
output from "(null)" to no output.
Thanks for catching this,
Thorsten
next prev parent reply other threads:[~2026-06-09 15:22 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-18 0:14 [PATCH RESEND] locking/lockdep: Replace snprintf with strscpy in seq_stats Thorsten Blum
2026-03-18 15:43 ` Waiman Long
2026-03-18 16:44 ` Boqun Feng
2026-06-09 13:54 ` Boqun Feng
2026-06-09 15:22 ` Thorsten Blum [this message]
2026-03-18 20:37 ` Peter Zijlstra
2026-04-14 15:46 ` Thorsten Blum
-- strict thread matches above, loose matches on Subject: below --
2026-02-22 20:40 Thorsten Blum
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=aigvpfqvTlDYDp7r@linux.dev \
--to=thorsten.blum@linux.dev \
--cc=boqun@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=longman@redhat.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--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