Re: [PATCH] x86: uaccess: fix regression in unsafe_get_user

From: Arthur Gautier
Date: Sat Feb 16 2019 - 22:41:41 EST


On Sat, Feb 16, 2019 at 11:47:02PM +0000, Al Viro wrote:
> On Sat, Feb 16, 2019 at 02:50:15PM -0800, Andy Lutomirski wrote:
>
> > What is the actual problem? Weâre not actually demand-faulting this data, are we? Are we just overrunning the buffer because the from_user helpers are too clever? Can we fix it for real by having the fancy helpers do *aligned* loads so that they donât overrun the buffer? Heck, this might be faster, too.
>
> Unaligned _stores_ are not any cheaper, and you'd get one hell of
> extra arithmetics from trying to avoid both. Check something
> like e.g. memcpy() on alpha, where you really have to keep all
> accesses aligned, both on load and on store side.
>
> Can't we just pad the buffers a bit? Making sure that name_buf
> and symlink_buf are _not_ followed by unmapped pages shouldn't
> be hard. Both are allocated by kmalloc(), so...

We cannot change alignment rules here. The input buffer string we're
reading is coming from an cpio formated file and the format is
defined by cpio(5).
Nothing much we can do there I'm afraid. Input buffer is defined to
be 4-byte aligned.

--
\o/ Arthur
G Gandi.net