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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <eaad272203baa65ad65ac2206e5197595c88508e.camel@HansenPartnership.com>
Date:   Tue, 27 Dec 2022 07:38:41 -0500
From:   James Bottomley <James.Bottomley@...senPartnership.com>
To:     Helge Deller <deller@....de>, yang.yang29@....com.cn
Cc:     linux-parisc@...r.kernel.org, linux-kernel@...r.kernel.org,
        xu.panda@....com.cn
Subject: Re: [PATCH linux-next] parisc: use strscpy() to instead of strncpy()

On Fri, 2022-12-23 at 08:55 +0100, Helge Deller wrote:
> On 12/23/22 03:40, yang.yang29@....com.cn wrote:
> > From: Xu Panda <xu.panda@....com.cn>
> > 
> > The implementation of strscpy() is more robust and safer.
> > That's now the recommended way to copy NUL-terminated strings.
> 
> Thanks for your patch, but....
> 
> > Signed-off-by: Xu Panda <xu.panda@....com.cn>
> > Signed-off-by: Yang Yang <yang.yang29@....com>
> > ---
> >   drivers/parisc/pdc_stable.c | 9 +++------
> >   1 file changed, 3 insertions(+), 6 deletions(-)
> > 
> > diff --git a/drivers/parisc/pdc_stable.c
> > b/drivers/parisc/pdc_stable.c
> > index d6af5726ddf3..403bca0021c5 100644
> > --- a/drivers/parisc/pdc_stable.c
> > +++ b/drivers/parisc/pdc_stable.c
> > @@ -274,8 +274,7 @@ pdcspath_hwpath_write(struct pdcspath_entry
> > *entry, const char *buf, size_t coun
> > 
> >         /* We'll use a local copy of buf */
> >         count = min_t(size_t, count, sizeof(in)-1);
> > -       strncpy(in, buf, count);
> > -       in[count] = '\0';
> > +       strscpy(in, buf, count + 1);
> 
> could you resend it somewhat simplified, e.g.
> strscpy(in, buf, sizeof(in));

I don't think you can: count is the size of buf, if that's < sizeof(in)
you've introduced a write beyond end of buffer.  In fact sysfs tends to
pass pages as buffers, so there's no actual problem, but if that ever
changed ...

James

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ