Re: [RFC PATCH] userfaultfd: Address race after fault.

From: Brian Geffon
Date: Mon Feb 17 2020 - 20:51:02 EST


Hi Peter,
I'll try helping out by giving the entire patchset a try.

But in the meantime, if the plan of record will be to always allow
retrying then shouldn't the block I mailed a patch on be removed
regardless because do_user_addr_fault always starts with
FAULT_FLAG_ALLOW_RETRY and we shouldn't ever land there without it in
the future and allows userfaultfd to retry?

Thanks,
Brian

On Mon, Feb 17, 2020 at 10:07 AM Peter Xu <peterx@xxxxxxxxxx> wrote:
>
> On Sat, Feb 15, 2020 at 09:29:46AM -0500, Brian Geffon wrote:
> > Hi Andrea,
> > Thanks for the quick reply. That's great to hear that Peter has been
> > working on those improvements. I didn't try the entire patchset but I
> > did confirm that patch 13, not surprisingly, also resolves that issue
> > on at least on x86:
> > https://lkml.org/lkml/2019/9/26/179
> >
> > Given that seems pretty low risk and it definitely resolves a pretty
> > big issue for the non-cooperative userfaultfd case, any chance it
> > could be landed ahead of the rest of the series?
>
> Thanks Andrea & Brian! Yes it would be great if the series (or some
> of the patches) could be moved forward. Please just let me know if
> there's still anything I can do from my side.
>
> Thanks,
>
> >
> > Thanks,
> > Brian
> >
> > On Fri, Feb 14, 2020 at 6:20 PM Andrea Arcangeli <aarcange@xxxxxxxxxx> wrote:
> > >
> > > Hello,
> > >
> > > this and other enhancements have already implemented by Peter (CC'ed)
> > > and in the right way, by altering the retry logic in the page fault
> > > code. This is a requirement for other kind of usages too, notably the
> > > UFFD_WRITEPROTECT ioctl after which multiple consecutive faults can
> > > happen and must be handled.
> > >
> > > IIRC Kirill asked at last LSF-MM uffd-wp talk if there's any
> > > particular reason the fault couldn't be retried currently. I had no
> > > sure answer other than there's apparently no strong reason why
> > > VM_FAULT_RETRY is only allowed 1 time currently, so there should be no
> > > issue in lifting that artificial restriction.
> > >
> > > I'm running with this patchset applied in my systems since Nov with no
> > > regression at all. I got sidetracked by various other issues, so
> > > unfortunately I didn' post a proper reviewed-by on the last submit yet
> > > (pending), but I did at least test it and it was rock solid so far.
> > >
> > > https://lore.kernel.org/lkml/20190926093904.5090-1-peterx@xxxxxxxxxx/
> > >
> > > Can you test and verify it too if it solves your use case?
> > >
> > > Also note the complete uffd-WP support submit also from Peter:
> > >
> > > https://lore.kernel.org/lkml/20190620022008.19172-1-peterx@xxxxxxxxxx/
> > >
> > > https://github.com/xzpeter/linux/tree/uffd-wp-merged
> > >
> > > Thanks,
> > > Andrea
> > >
> >
>
> --
> Peter Xu
>