lkml.org 
[lkml]   [2020]   [Feb]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH -next] fork: annotate a data race in vm_area_dup()
From
Date


> On Feb 17, 2020, at 5:31 PM, Kirill A. Shutemov <kirill@shutemov.name> wrote:
>
> I'm confused. AFAICS both sides hold mmap_sem on write:
>
> - vm_mmap_pgoff() takes mmap_sem for the write on the write side
>
> - do_mprotect_pkey() takes mmap_sem for the write on the read side
>
>
> What do I miss?

Ah, good catch. I missed the locking for the read there. This is interesting because Marco
did confirmed that the concurrency could happen,

https://lore.kernel.org/lkml/20191025173511.181416-1-elver@google.com/

If that means KCSAN is not at fault, then I could think of two things,

1) someone downgrades the lock.

I don’t think that a case here. Only __do_munmap() will do that but I did not see how
it will affect us here.

2) the reader and writer are two different processes.

So, they held a different mmap_sem, but I can’t see how could two processes shared
the same vm_area_struct. Also, file->f_mapping->i_mmap was also stored in the
writer, but I can’t see how it was also loaded in the reader.

Any ideas?
\
 
 \ /
  Last update: 2020-02-18 05:01    [W:1.858 / U:0.108 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site