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>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAH4c4jLn78OYPqqEESh6vRhxfD8s=J8a-cX0WzVE1bEPKVAHEg@mail.gmail.com>
Date: Tue, 17 Jun 2025 18:53:23 +0530
From: Pranav Tyagi <pranav.tyagi03@...il.com>
To: Greg KH <gregkh@...uxfoundation.org>
Cc: cem@...nel.org, skhan@...uxfoundation.org, linux-xfs@...r.kernel.org, 
	linux-kernel@...r.kernel.org, linux-kernel-mentees@...ts.linux.dev
Subject: Re: [PATCH] fs/xfs: use scnprintf() in show functions

On Mon, Jun 16, 2025 at 7:50 PM Greg KH <gregkh@...uxfoundation.org> wrote:
>
> On Mon, Jun 16, 2025 at 04:33:13PM +0530, Pranav Tyagi wrote:
> > Replace all snprintf() instances with scnprintf(). snprintf() returns
> > the number of bytes that would have been written had there been enough
> > space. For sysfs attributes, snprintf() should not be used for the
> > show() method. Instead use scnprintf() which returns the number of bytes
> > actually written.
>
> No, please use sysfs_emit() if you really want to change this.
>
> >
> > Signed-off-by: Pranav Tyagi <pranav.tyagi03@...il.com>
> > ---
> >  fs/xfs/xfs_sysfs.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/fs/xfs/xfs_sysfs.c b/fs/xfs/xfs_sysfs.c
> > index 7a5c5ef2db92..f7206e3edea2 100644
> > --- a/fs/xfs/xfs_sysfs.c
> > +++ b/fs/xfs/xfs_sysfs.c
> > @@ -257,7 +257,7 @@ larp_show(
> >       struct kobject  *kobject,
> >       char            *buf)
> >  {
> > -     return snprintf(buf, PAGE_SIZE, "%d\n", xfs_globals.larp);
>
> There is nothing wrong with the original code here, you could use
> sprintf() and it too is ok.  So this type of change is not needed.  But
> again, if you really want to, use sysfs_emit() instead.
>
> Same for all the other show() callback changes you just made.
>
> thanks,
>
> greg k-h

Hi,

Thanks for the feedback. I understand the original code is
perfectly fine. All these show callback changes were intended as
cleanups. I'll drop these patches. And will use sysfs_emit() if
I ever have to.

Regards
Pranav Tyagi

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ