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] [day] [month] [year] [list]
Message-ID: <20110603224133.GQ11521@ZenIV.linux.org.uk>
Date:	Fri, 3 Jun 2011 23:41:33 +0100
From:	Al Viro <viro@...IV.linux.org.uk>
To:	Alexey Dobriyan <adobriyan@...il.com>
Cc:	Scott Wood <scottwood@...escale.com>,
	Timur Tabi <timur@...escale.com>, alan@...rguk.ukuu.org.uk,
	linux-kernel@...r.kernel.org, akpm@...ux-foundation.org
Subject: Re: [PATCH] lib: introduce strdup_from_user

On Fri, Jun 03, 2011 at 10:12:37PM +0300, Alexey Dobriyan wrote:

> Because now you're lucky C strings are NUL-terminated.
> If this "idiom" applies to some other case like "validate + copy",
> we have a bug.
> 
> We copy data to kernelspace THEN validate or copy or whatever.
> This is obviously correct and safe.

In this case we don't know how _much_ needs to be copied, and that information
comes precisely from NUL-termination.  IOW, it's not a matter of luck at all.

"Copy the amount of bytes equal to the limit given to us, then truncate if
needed" is seriously broken in this case.  Think what happens if you have
a short string sitting in the middle of a page, with the next page not
mapped at all.  And ask to copy up to 4096 bytes.  The string itself is
much shorter than that.  However, trying to blindly copy those 4096 bytes
will give you -EFAULT.  Which is not what we want when copying strings
from userland.

We certainly do not want to *reread* them, but this "find the length, then
copy that much" is just fine.
--
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