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: <17e5e7c31b2347a6b87c6533c59899d0@AcuMS.aculab.com>
Date: Sat, 10 Jun 2023 19:31:42 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Rasmus Villemoes' <linux@...musvillemoes.dk>, Petr Mladek
	<pmladek@...e.com>, Kees Cook <keescook@...omium.org>
CC: Richard Weinberger <richard@....at>, "linux-hardening@...r.kernel.org"
	<linux-hardening@...r.kernel.org>, "netdev@...r.kernel.org"
	<netdev@...r.kernel.org>, "linux-kernel@...r.kernel.org"
	<linux-kernel@...r.kernel.org>, Steven Rostedt <rostedt@...dmis.org>, "Sergey
 Senozhatsky" <senozhatsky@...omium.org>, Andy Shevchenko
	<andriy.shevchenko@...ux.intel.com>, "David S. Miller" <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>, "Paolo
 Abeni" <pabeni@...hat.com>, Miguel Ojeda <ojeda@...nel.org>, Alex Gaynor
	<alex.gaynor@...il.com>, Wedson Almeida Filho <wedsonaf@...il.com>, "Boqun
 Feng" <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
	Björn Roy Baron <bjorn3_gh@...tonmail.com>, Benno Lossin
	<benno.lossin@...ton.me>, Alexei Starovoitov <ast@...nel.org>, "Daniel
 Borkmann" <daniel@...earbox.net>, Jesper Dangaard Brouer <hawk@...nel.org>,
	John Fastabend <john.fastabend@...il.com>
Subject: RE: [RFC PATCH 0/1] Integer overflows while scanning for integers

From: Rasmus Villemoes
> Sent: 09 June 2023 11:10
> 
> On 08/06/2023 17.27, Petr Mladek wrote:
> > On Wed 2023-06-07 16:36:12, Kees Cook wrote:
> 
> > It seems that userspace implementation of sscanf() and vsscanf()
> > returns -ERANGE in this case. It might be a reasonable solution.
> 
> Well. _Some_ userspace implementation does that. It's not in POSIX.
> While "man scanf" lists that ERANGE error, it also explicitly says that:
> 
> CONFORMING TO
>        The functions fscanf(), scanf(), and sscanf() conform to C89 and
> C99 and POSIX.1-2001.  These standards do  not  specify  the
>        ERANGE error.
> 
> I can't figure out what POSIX actually says should or could happen with
> sscanf("99999999999999", "%i", &x);

Possibly 'undefined behaviour' - they like that one.

But I'm sure I remember the ToG 'Unix' definition not requiring that
'utilities' check for overflow on numeric command line parameters.
(It might even have said they wouldn't check.)
So it was perfectly valid for a stupidly out of range value
to be treated as a different (possibly valid) value.

What is clearly wrong is to just stop processing the
input string.
sscanf("9999999999999999999scale", "%i%s", &x, &scale)
writing any '9' to scale is clearly broken.

Personally I avoid scanf() - it is far too easy for it to do
something you didn't really intend.

	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