Message ID | 20190526173325.lpt5qtg7c6rnbql5@linutronix.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | x86/fpu: Use fault_in_pages_writeable() for pre-faulting | expand |
On 2019-05-26 19:33:25 [+0200], To Hugh Dickins wrote: > From: Hugh Dickins <hughd@google.com> … > Signed-off-by: Hugh Dickins <hughd@google.com> Hugh, I took your patch, slapped a signed-off-by line. Please say that you are fine with it (or object otherwise). Sebastian
On Sun, 26 May 2019, Sebastian Andrzej Siewior wrote: > On 2019-05-26 19:33:25 [+0200], To Hugh Dickins wrote: > From: Hugh Dickins <hughd@google.com> > … > > Signed-off-by: Hugh Dickins <hughd@google.com> > > Hugh, I took your patch, slapped a signed-off-by line. Please say that > you are fine with it (or object otherwise). I'm fine with it, thanks Sebastian. Sorry if I wasted your time by not giving it my sign-off in the first place, but I was not comfortable to dabble there without your sign-off too - which it now has. (And thought you might already have your own version anyway: just provided mine as illustration, so that we could be sure of exactly what I'd been testing.) Hugh
On Sun, 26 May 2019 19:33:25 +0200 Sebastian Andrzej Siewior <bigeasy@linutronix.de> wrote: > From: Hugh Dickins <hughd@google.com> > > Since commit > > d9c9ce34ed5c8 ("x86/fpu: Fault-in user stack if copy_fpstate_to_sigframe() fails") Please add this as a Fixes: d9c9ce34ed5c8 ("x86/fpu: Fault-in user stack if copy_fpstate_to_sigframe() fails") line so that anyone who backports d9c9ce34ed5c8 has a chance of finding this patch also.
diff --git a/arch/x86/kernel/fpu/signal.c b/arch/x86/kernel/fpu/signal.c index 5a8d118bc423e..060d6188b4533 100644 --- a/arch/x86/kernel/fpu/signal.c +++ b/arch/x86/kernel/fpu/signal.c @@ -5,6 +5,7 @@ #include <linux/compat.h> #include <linux/cpu.h> +#include <linux/pagemap.h> #include <asm/fpu/internal.h> #include <asm/fpu/signal.h> @@ -189,15 +190,7 @@ int copy_fpstate_to_sigframe(void __user *buf, void __user *buf_fx, int size) fpregs_unlock(); if (ret) { - int aligned_size; - int nr_pages; - - aligned_size = offset_in_page(buf_fx) + fpu_user_xstate_size; - nr_pages = DIV_ROUND_UP(aligned_size, PAGE_SIZE); - - ret = get_user_pages_unlocked((unsigned long)buf_fx, nr_pages, - NULL, FOLL_WRITE); - if (ret == nr_pages) + if (!fault_in_pages_writeable(buf_fx, fpu_user_xstate_size)) goto retry; return -EFAULT; }