Re: [PATCH v7 05/19] iov_iter: Introduce fault_in_iov_iter_writeable
From: Al Viro
Date: Sat Aug 28 2021 - 18:19:18 EST
On Sat, Aug 28, 2021 at 10:11:36PM +0000, Al Viro wrote:
> On Sat, Aug 28, 2021 at 10:04:41PM +0000, Al Viro wrote:
> > On Sat, Aug 28, 2021 at 11:47:03PM +0200, Thomas Gleixner wrote:
> >
> > > /* Try to handle #PF, but anything else is fatal. */
> > > if (ret != -EFAULT)
> > > return -EINVAL;
> >
> > > which all end up in user_insn(). user_insn() returns 0 or the negated
> > > trap number, which results in -EFAULT for #PF, but for #MC the negated
> > > trap number is -18 i.e. != -EFAULT. IOW, there is no endless loop.
> > >
> > > This used to be a problem before commit:
> > >
> > > aee8c67a4faa ("x86/fpu: Return proper error codes from user access functions")
> > >
> > > and as the changelog says the initial reason for this was #GP going into
> > > the fault path, but I'm pretty sure that I also discussed the #MC angle with
> > > Borislav back then. Should have added some more comments there
> > > obviously.
> >
> > ... or at least have that check spelled
> >
> > if (ret != -X86_TRAP_PF)
> > return -EINVAL;
> >
> > Unless I'm misreading your explanation, that is...
>
> BTW, is #MC triggered on stored to a poisoned cacheline? Existence of CLZERO
> would seem to argue against that...
How about taking __clear_user() out of copy_fpregs_to_sigframe()
and replacing the call of fault_in_pages_writeable() with
if (!clear_user(buf_fx, fpu_user_xstate_size))
goto retry;
return -EFAULT;
in the caller?