Re: [PATCH RESEND] locking/lockdep: Replace snprintf with strscpy in seq_stats

From: Boqun Feng

Date: Tue Jun 09 2026 - 10:01:05 EST


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@xxxxxxxxxx>
> > > Signed-off-by: Thorsten Blum <thorsten.blum@xxxxxxxxx>
> > > ---
> > > 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@xxxxxxxxxx>
> >
>
> 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?

Regards,
Boqun

> Regards,
> Boqun