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: <87383cui8k.fsf@rasmusvillemoes.dk>
Date:	Mon, 04 May 2015 23:48:27 +0200
From:	Rasmus Villemoes <linux@...musvillemoes.dk>
To:	Alexey Dobriyan <adobriyan@...il.com>
Cc:	Andrew Morton <akpm@...ux-foundation.org>,
	Linux Kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 01/10] Add parse_integer() (replacement for simple_strto*())

On Mon, May 04 2015, Alexey Dobriyan <adobriyan@...il.com> wrote:

>> There are lots of callers of memparse(), and I don't think any of them
>> are prepared to handle *endp ending up pointing before the passed-in
>> string (-EINVAL == -22, -ERANGE == -34). I can easily see how that could
>> lead to an infinite loop, maybe worse.
>
> Yeah, possible bug could become worse, I'll add error checking,
> but, seriously, you're defending this :^)
>
> 	case Opt_nr_inodes:
> ===>		/* memparse() will accept a K/M/G without a digit */
> ===>		if (!isdigit(*args[0].from))
> ===>			goto bad_val;
> 		pconfig->nr_inodes = memparse(args[0].from, &rest);
> 		break;
>

No, I'm not defending memparse(), simple_strto* or any of their
callers. I'm just trying to say that you can't change the semantics of
memparse() without considering all its callers.

I don't think there's any way to "add error checking" and preserve the
exact memparse() semantic - in other words, I don't think simple_strto*
can actually be implemented in terms of parse_integer. But that's not a
bad thing - we want to get rid of those.

> memparse() is misdesigned in the same sense strtoul() is misdesigned.
> Every "memparse(s, NULL)" user is a bug for example.

Yes, memparse is misdesigned, since it doesn't have a way to indicate
error. That leads me to: There's no point in adding error checking to
the integer parsing part without also checking the left shifts for
overflow.

I think the right approach is to rename memparse to legacy_memparse and
introduce a memparse with semantics that allow error checking. One could
start by introducing that under the name sane_memparse. But there are
probably lots of simple_strto*() uses that are easier to eliminate.

Rasmus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ