From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-181.mta0.migadu.com (out-181.mta0.migadu.com [91.218.175.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 53D24327C0D for ; Tue, 9 Jun 2026 15:22:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781018542; cv=none; b=evipUblFbgLYVKMaI5T4vY5+I1C7nVfSNKD9GuDYL9yk6lnHZb6DlpPCdTA5z1j6ruWDM5lY5cn4pGG60iIznugFXh9LvHBUIC8xGcv2YNt/tsRY3llvxNzyrmVf/LE3EMpgj9SWDKqHMv5UquIJE16Qf9ZAsQByRICbwy7w0iQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781018542; c=relaxed/simple; bh=DOSbshxqobPnhpFT25nG7qdqFafwQ3z4Uyt0YHH9RKs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=QWJt/cL243fNXf5eAXVhqxyjnfDRNM68t7yoTvzdezkvevjpgkQZuPWmNpiaZQvYYv1p35RtmZxcDW24BQRc7WjcRGefS2bnj0V3WdqIh8toXwonBEKuTEzB5ABqHHx4ttCiaAvjehjjqN5zyJhUbT87tVDaTYIu4Z1IkEYqhLs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=GA9Zd9ph; arc=none smtp.client-ip=91.218.175.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="GA9Zd9ph" Date: Tue, 9 Jun 2026 17:22:13 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1781018537; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=hDtYMd4akYLqhnw4QVztzvDbjHO+yBnKDdo+eOfKsLw=; b=GA9Zd9phxCYQgeCQfx2CVughhwVf5ozHP+S+g9j2dvdon32NXdYjYQkVMfQlmHxSyb7ill UblKhgnSk1T7OJ3eFC44iwGNJpy/1smVGhaDcNvXsK5iR49RIdDs+4Ue1x9IJLec9YuZdg c4kyUrpTOA2fbtgUvcFN2iU6duGrd5I= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Thorsten Blum To: Boqun Feng Cc: Waiman Long , Peter Zijlstra , Ingo Molnar , Will Deacon , linux-kernel@vger.kernel.org Subject: Re: [PATCH RESEND] locking/lockdep: Replace snprintf with strscpy in seq_stats Message-ID: References: <20260318001426.2664-3-thorsten.blum@linux.dev> <1a5b1a90-6445-4949-abce-6ec799b959b1@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT 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 > > > > Signed-off-by: Thorsten Blum > > > > --- > > > > 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 > > > > #include > > > > #include > > > > +#include > > > > #include > > > > #include > > > > @@ -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 > > > > > > > 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