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

2019-10-10 Thread Arthur Gautier
On Thu, Sep 26, 2019 at 04:09:39PM +0200, Borislav Petkov wrote: > On Thu, Sep 26, 2019 at 09:58:25AM +, Arthur Gautier wrote: > > I think Andy submitted a patch Feb 25 2019, but I was not copied on it > > (I believe it was sent to x...@kernel.org) and I don't know which fate it > > had. > > I

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

2019-09-26 Thread Borislav Petkov
On Thu, Sep 26, 2019 at 09:58:25AM +, Arthur Gautier wrote: > I think Andy submitted a patch Feb 25 2019, but I was not copied on it > (I believe it was sent to x...@kernel.org) and I don't know which fate it > had. I guess we're still waiting for Andy to do v2 with feedback incorporated and p

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

2019-09-26 Thread Borislav Petkov
On Mon, Feb 18, 2019 at 11:15:44AM -0800, Andy Lutomirski wrote: > diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c > index 58eacd41526c..709d6efe0d42 100644 > --- a/lib/strncpy_from_user.c > +++ b/lib/strncpy_from_user.c > @@ -10,12 +10,7 @@ > #include > #include > > -#ifdef CO

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

2019-09-26 Thread Arthur Gautier
On Mon, Feb 18, 2019 at 09:51:50PM +, Arthur Gautier wrote: > On Mon, Feb 18, 2019 at 11:15:44AM -0800, Andy Lutomirski wrote: > > This seems like it's just papering over the underlying problem: with > > Jann's new checks in place, strncpy_from_user() is simply buggy. Does > > the patch below

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

2019-02-18 Thread Arthur Gautier
On Mon, Feb 18, 2019 at 11:15:44AM -0800, Andy Lutomirski wrote: > This seems like it's just papering over the underlying problem: with > Jann's new checks in place, strncpy_from_user() is simply buggy. Does > the patch below look decent? It's only compile-tested, but it's > conceptually straight

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

2019-02-18 Thread Jann Horn
On Mon, Feb 18, 2019 at 8:15 PM Andy Lutomirski wrote: > On Mon, Feb 18, 2019 at 5:04 AM Thomas Gleixner wrote: > > > Another would be to have the buffer passed to flush_buffer() (i.e. > > > the callback of decompress_fn) allocated with 4 bytes of padding > > > past the part where the unpacked pi

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

2019-02-18 Thread Andy Lutomirski
On Mon, Feb 18, 2019 at 5:04 AM Thomas Gleixner wrote: > > Another would be to have the buffer passed to flush_buffer() (i.e. > > the callback of decompress_fn) allocated with 4 bytes of padding > > past the part where the unpacked piece of data is placed for the > > callback to find. As in, > >

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

2019-02-18 Thread Thomas Gleixner
On Sun, 17 Feb 2019, Al Viro wrote: > On Sun, Feb 17, 2019 at 03:41:21AM +, Arthur Gautier wrote: > Who says anything about changing the format of the file? At least > one trivial way to handle that would be this: > > diff --git a/init/initramfs.c b/init/initramfs.c > index 7cea802d00ef..edbd

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

2019-02-16 Thread Al Viro
On Sun, Feb 17, 2019 at 03:41:21AM +, Arthur Gautier wrote: > On Sat, Feb 16, 2019 at 11:47:02PM +, 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 w

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

2019-02-16 Thread Arthur Gautier
On Sat, Feb 16, 2019 at 11:47:02PM +, 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 c

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

2019-02-16 Thread Andy Lutomirski
> On Feb 16, 2019, at 3:47 PM, 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

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

2019-02-16 Thread Al Viro
On Sat, Feb 16, 2019 at 11:47:02PM +, 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 c

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

2019-02-16 Thread Al Viro
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 *alig

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

2019-02-16 Thread Andy Lutomirski
> On Feb 16, 2019, at 2:50 PM, Andy Lutomirski wrote: > > > >>> On Feb 16, 2019, at 12:18 PM, Thomas Gleixner wrote: >>> On Sat, 16 Feb 2019, Jann Horn wrote: On Sat, Feb 16, 2019 at 12:59 AM wrote: When extracting an initramfs, a filename may be near an allocation bou

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

2019-02-16 Thread Andy Lutomirski
> On Feb 16, 2019, at 12:18 PM, Thomas Gleixner wrote: > >> On Sat, 16 Feb 2019, Jann Horn wrote: >>> On Sat, Feb 16, 2019 at 12:59 AM wrote: >>> When extracting an initramfs, a filename may be near an allocation boundary. >>> Should that happen, strncopy_from_user will invoke unsafe_get_user

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

2019-02-16 Thread Thomas Gleixner
On Sat, 16 Feb 2019, Thomas Gleixner wrote: > On Sat, 16 Feb 2019, Jann Horn wrote: > > On Sat, Feb 16, 2019 at 12:59 AM wrote: > > > When extracting an initramfs, a filename may be near an allocation > > > boundary. > > > Should that happen, strncopy_from_user will invoke unsafe_get_user which

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

2019-02-16 Thread Thomas Gleixner
On Sat, 16 Feb 2019, Jann Horn wrote: > On Sat, Feb 16, 2019 at 12:59 AM wrote: > > When extracting an initramfs, a filename may be near an allocation boundary. > > Should that happen, strncopy_from_user will invoke unsafe_get_user which > > may cross the allocation boundary. Should that happen, u

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

2019-02-15 Thread Jann Horn
+Andy Lutomirski On Sat, Feb 16, 2019 at 12:59 AM wrote: > > From: Arthur Gautier > > When extracting an initramfs, a filename may be near an allocation boundary. > Should that happen, strncopy_from_user will invoke unsafe_get_user which > may cross the allocation boundary. Should that happen, u

[PATCH] x86: uaccess: fix regression in unsafe_get_user

2019-02-15 Thread baloo
From: Arthur Gautier When extracting an initramfs, a filename may be near an allocation boundary. Should that happen, strncopy_from_user will invoke unsafe_get_user which may cross the allocation boundary. Should that happen, unsafe_get_user will trigger a page fault, and strncopy_from_user would