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: <1a75240d27bb4f2abe3cfae49b2f7605@AcuMS.aculab.com>
Date: Mon, 15 Apr 2024 11:22:41 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Kees Cook' <keescook@...omium.org>, Justin Stitt <justinstitt@...gle.com>
CC: Chandan Babu R <chandan.babu@...cle.com>, "Darrick J. Wong"
	<djwong@...nel.org>, "linux-xfs@...r.kernel.org" <linux-xfs@...r.kernel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"linux-hardening@...r.kernel.org" <linux-hardening@...r.kernel.org>
Subject: RE: [PATCH] xfs: replace deprecated strncpy with strscpy_pad

From: Kees Cook
> Sent: 11 April 2024 16:32
> 
> On Wed, Apr 10, 2024 at 01:45:21PM -0700, Justin Stitt wrote:
> > On Tue, Apr 9, 2024 at 9:22 AM Kees Cook <keescook@...omium.org> wrote:
> > > >
> > > > -     /* 1 larger than sb_fname, so this ensures a trailing NUL char */
> > > > -     memset(label, 0, sizeof(label));
> > > >       spin_lock(&mp->m_sb_lock);
> > > > -     strncpy(label, sbp->sb_fname, XFSLABEL_MAX);
> > > > +     strscpy_pad(label, sbp->sb_fname);
> > >
> > > Is sbp->sb_fname itself NUL-terminated? This looks like another case of
> > > needing the memtostr() helper?
> > >
> >
> > I sent a patch [1].
> >
> > Obviously it depends on your implementation patch landing first; what
> > tree should it go to?
> 
> This "flavor" of conversion may need to wait a release? There's no
> urgency on the conversion, and there are plenty more to do for this
> cycle. ;)

In this case:
	char label[sizeof (sbp->fb_fname) + 1];
	memcpy(label, sbp->sb_fname, sizeof (sbp->sb_fname));
	label[sizeof (sbp->fname)] = 0;
is probably the clearest code.
(it is [12] - so no point faffing with the copy.)

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ