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] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 21 Aug 2018 15:57:34 +0200
From:   Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To:     Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>
Cc:     Rasmus Villemoes <linux@...musvillemoes.dk>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Arnd Bergmann <arnd@...db.de>, Martin Wilck <mwilck@...e.com>,
        Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
        linux-kernel@...r.kernel.org,
        Sergey Senozhatsky <sergey.senozhatsky@...il.com>
Subject: Re: [RFC][PATCH] lib/string: introduce sysfs_strncpy() and
 sysfs_strlcpy()

On Tue, Aug 21, 2018 at 06:50:55PM +0900, Sergey Senozhatsky wrote:
> Hi Rasmus,
> 
> On (08/21/18 09:59), Rasmus Villemoes wrote:
> > > +char *sysfs_strncpy(char *dest, const char *src, size_t count)
> > > +{
> > > +	char *c;
> > > +
> > > +	strncpy(dest, skip_spaces(src), count);
> > 
> > I'd like to see where and how you'd use this, but I'm very skeptical of
> > count being used both for the size of the dest buffer as well as an
> > essentially random argument to strncpy - if count is also the maximum
> > number of bytes to read from the src, you'd need to take the
> > skip_spaces() into account, because there are not count bytes left after
> > that...
> > And if src is not necessarily nul-terminated, skip_spaces() by
> > itself is wrong.
> 
> I think that sysfs input is always properly NULL-terminated. It may or
> may not contain \n, but \0 is expected to be there. Am I wrong?

sysfs data is always null terminated.

What exactly are you trying to do here?  If a user sends you crappy data
in a sysfs file (like leading or trailing whitespace), well, you can
always just error out, no problem.  You can be very strict in the
SINGLE_VALUE that you accept in your sysfs file.  And yes, sysfs files
are single values, if you want to do more than that, you need to use
something else, so I really do not understand what problem you are
trying to solve here.

Please always post a user of your new api when you make stuff like this
otherwise we do not know how it is used, or even why you are adding it.

thanks,

greg k-h

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ