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]
Message-ID: <bb500daac1dc4cd9abd3f5e39f9329be@AcuMS.aculab.com>
Date: Tue, 22 Oct 2024 11:07:46 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Bartosz Golaszewski' <brgl@...ev.pl>, Jiri Slaby <jirislaby@...nel.org>
CC: Kees Cook <kees@...nel.org>, Andy Shevchenko <andy@...nel.org>, "Andrew
 Morton" <akpm@...ux-foundation.org>, James Bottomley
	<James.Bottomley@...senpartnership.com>, Greg KH
	<gregkh@...uxfoundation.org>, "linux-hardening@...r.kernel.org"
	<linux-hardening@...r.kernel.org>, "linux-kernel@...r.kernel.org"
	<linux-kernel@...r.kernel.org>, Bartosz Golaszewski
	<bartosz.golaszewski@...aro.org>, "stable@...r.kernel.org"
	<stable@...r.kernel.org>
Subject: RE: [PATCH] lib: string_helpers: fix potential snprintf() output
 truncation

From: Bartosz Golaszewski
> Sent: 22 October 2024 08:30
> 
> On Tue, Oct 22, 2024 at 9:15 AM Jiri Slaby <jirislaby@...nel.org> wrote:
> >
> > On 21. 10. 24, 12:04, Bartosz Golaszewski wrote:
> > > From: Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
> > >
> > > The output of ".%03u" with the unsigned int in range [0, 4294966295] may
> > > get truncated if the target buffer is not 12 bytes.
> >
> > Perhaps, if you elaborate on how 'remainder' can become > 999?
> >
> 
> Yeah, I guess it can't. Not sure what we do about such false
> positives, do we have some common way to suppress them?

The only way I've found is to 'launder' the buffer size using
OPTIMISER_HIDE_VAR().
Although I can imagine an update to gcc that checks sizeof (buffer)
as well - so that would also need laundering.

You actually want:
#define OPTIMER_HIDE_VAL(x) \
  ({ __auto_type _x = x; OPTIMER_HIDE_VAR(_x); _x;})
so you can do:
	snprintf(OPTIMISER_HIDE_VAL(buffer), OPTOMISER_HIDE_VAL(sizeof buffer), fmt, ...)

Perhaps that could be snprint_truncate() ?

	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