Re: [PATCH] userfaultfd: prevent non-cooperative events vs mcopy_atomic races

2020-12-08 Thread Nadav Amit
> On Dec 8, 2020, at 12:34 AM, Mike Rapoport wrote: > > On Sun, Dec 06, 2020 at 08:31:39PM -0800, Nadav Amit wrote: >> Whenever I run into a non-standard and non-trivial synchronization algorithm >> in the kernel (and elsewhere), I become very confused and concerned. I >> raised my question since

Re: [PATCH] userfaultfd: prevent non-cooperative events vs mcopy_atomic races

2020-12-08 Thread Mike Rapoport
On Sun, Dec 06, 2020 at 08:31:39PM -0800, Nadav Amit wrote: > > Whenever I run into a non-standard and non-trivial synchronization algorithm > in the kernel (and elsewhere), I become very confused and concerned. I > raised my question since I wanted to modify the code and could not figure > out ho

Re: [PATCH] userfaultfd: prevent non-cooperative events vs mcopy_atomic races

2020-12-06 Thread Nadav Amit
Thanks for the detailed answer, Mike. Things are clearer in regard to your intention. > On Dec 6, 2020, at 1:37 AM, Mike Rapoport wrote: > > The uffd monotor should *know* what is the state of child's memory and > without this patch it could only guess. I see - so mmap_changing is not just abou

Re: [PATCH] userfaultfd: prevent non-cooperative events vs mcopy_atomic races

2020-12-06 Thread Mike Rapoport
Hello Nadav, On Thu, Dec 03, 2020 at 11:57:46AM -0800, Nadav Amit wrote: > Hello Mike, > > Regarding your (old) patch: > > > On May 23, 2018, at 12:42 AM, Mike Rapoport wrote: > > > > If a process monitored with userfaultfd changes it's memory mappings or > > forks() at the same time as uffd m

Re: [PATCH] userfaultfd: prevent non-cooperative events vs mcopy_atomic races

2020-12-03 Thread Nadav Amit
Hello Mike, Regarding your (old) patch: > On May 23, 2018, at 12:42 AM, Mike Rapoport wrote: > > If a process monitored with userfaultfd changes it's memory mappings or > forks() at the same time as uffd monitor fills the process memory with > UFFDIO_COPY, the actual creation of page table entr

Re: [PATCH] userfaultfd: prevent non-cooperative events vs mcopy_atomic races

2018-05-25 Thread Pavel Emelyanov
>> But doesn't it race even with regular PF handling, not only the fork? How >> do we handle this race? > > With the regular #PF handing, the faulting thread patiently waits until > page fault is resolved. With fork(), mremap() etc the thread that caused > the event resumes once the uffd message

Re: [PATCH] userfaultfd: prevent non-cooperative events vs mcopy_atomic races

2018-05-24 Thread Mike Rapoport
On Thu, May 24, 2018 at 07:40:07PM +0300, Pavel Emelyanov wrote: > On 05/24/2018 02:56 PM, Mike Rapoport wrote: > > On Thu, May 24, 2018 at 02:24:37PM +0300, Pavel Emelyanov wrote: > >> On 05/23/2018 10:42 AM, Mike Rapoport wrote: > >>> If a process monitored with userfaultfd changes it's memory ma

Re: [PATCH] userfaultfd: prevent non-cooperative events vs mcopy_atomic races

2018-05-24 Thread Pavel Emelyanov
On 05/24/2018 02:56 PM, Mike Rapoport wrote: > On Thu, May 24, 2018 at 02:24:37PM +0300, Pavel Emelyanov wrote: >> On 05/23/2018 10:42 AM, Mike Rapoport wrote: >>> If a process monitored with userfaultfd changes it's memory mappings or >>> forks() at the same time as uffd monitor fills the process

Re: [PATCH] userfaultfd: prevent non-cooperative events vs mcopy_atomic races

2018-05-24 Thread Mike Rapoport
On Thu, May 24, 2018 at 02:24:37PM +0300, Pavel Emelyanov wrote: > On 05/23/2018 10:42 AM, Mike Rapoport wrote: > > If a process monitored with userfaultfd changes it's memory mappings or > > forks() at the same time as uffd monitor fills the process memory with > > UFFDIO_COPY, the actual creation

Re: [PATCH] userfaultfd: prevent non-cooperative events vs mcopy_atomic races

2018-05-24 Thread Pavel Emelyanov
On 05/23/2018 10:42 AM, Mike Rapoport wrote: > If a process monitored with userfaultfd changes it's memory mappings or > forks() at the same time as uffd monitor fills the process memory with > UFFDIO_COPY, the actual creation of page table entries and copying of the > data in mcopy_atomic may happ

[PATCH] userfaultfd: prevent non-cooperative events vs mcopy_atomic races

2018-05-23 Thread Mike Rapoport
If a process monitored with userfaultfd changes it's memory mappings or forks() at the same time as uffd monitor fills the process memory with UFFDIO_COPY, the actual creation of page table entries and copying of the data in mcopy_atomic may happen either before of after the memory mapping modifica