Re: Multiple potential races on vma->vm_flags

2015-10-15 Thread Andrey Konovalov
On Wed, Oct 14, 2015 at 12:33 AM, Hugh Dickins wrote: > I think I've found the answer to that at last: we were indeed > all looking in the wrong direction. Your ktsan tree shows > > static __always_inline int atomic_add_negative(int i, atomic_t *v) > { > #ifndef CONFIG_KTSAN > GEN_BINARY_

Re: Multiple potential races on vma->vm_flags

2015-10-13 Thread Hugh Dickins
On Wed, 23 Sep 2015, Sasha Levin wrote: > On 09/23/2015 09:08 AM, Andrey Konovalov wrote: > > On Wed, Sep 23, 2015 at 3:39 AM, Hugh Dickins wrote: > >> > This is totally untested, and one of you may quickly prove me wrong; > >> > but I went in to fix your "Bad page state (mlocked)" by holding pte

Re: Multiple potential races on vma->vm_flags

2015-10-13 Thread Hugh Dickins
On Wed, 23 Sep 2015, Andrey Konovalov wrote: > On Wed, Sep 23, 2015 at 3:39 AM, Hugh Dickins wrote: > > This is totally untested, and one of you may quickly prove me wrong; > > but I went in to fix your "Bad page state (mlocked)" by holding pte > > lock across the down_read_trylock of mmap_sem in

Re: Multiple potential races on vma->vm_flags

2015-09-25 Thread Kirill A. Shutemov
On Wed, Sep 23, 2015 at 08:42:26PM -0400, Sasha Levin wrote: > On 09/23/2015 09:08 AM, Andrey Konovalov wrote: > > On Wed, Sep 23, 2015 at 3:39 AM, Hugh Dickins wrote: > >> > This is totally untested, and one of you may quickly prove me wrong; > >> > but I went in to fix your "Bad page state (mloc

Re: Multiple potential races on vma->vm_flags

2015-09-25 Thread Oleg Nesterov
On 09/23, Sasha Levin wrote: > > Another similar trace where we see a problem during process exit: > > [1922964.887922] kasan: GPF could be caused by NULL-ptr deref or user memory > accessgeneral protection fault: [#1] PREEMPT SMP DEBUG_PAGEALLOC KASAN > [1922964.890234] Modules linked in: >

Re: Multiple potential races on vma->vm_flags

2015-09-25 Thread Oleg Nesterov
On 09/24, Andrey Ryabinin wrote: > > 2015-09-24 20:26 GMT+03:00 Oleg Nesterov : > > On 09/24, Sasha Levin wrote: > >> > >> void unmap_vmas(struct mmu_gather *tlb, > >> struct vm_area_struct *vma, unsigned long start_addr, > >> unsigned long end_addr) > >> { > >>

Re: Multiple potential races on vma->vm_flags

2015-09-24 Thread Sasha Levin
On 09/24/2015 02:52 PM, Andrey Ryabinin wrote: > Sasha, could you confirm that in your kernel mmu_notifier_mm field has > 0x4c8 offset? > I would use gdb for that: > gdb vmlinux > (gdb) p/x &(((struct mm_struct*)0)->mmu_notifier_mm) (gdb) p/x &(((struct mm_struct*)0)->mmu_notifier_mm) $1 = 0x4c8

Re: Multiple potential races on vma->vm_flags

2015-09-24 Thread Andrey Ryabinin
2015-09-24 20:26 GMT+03:00 Oleg Nesterov : > On 09/24, Sasha Levin wrote: >> >> On 09/24/2015 09:11 AM, Oleg Nesterov wrote: >> > >> > Well, I know absolutely nothing about kasan, to the point I can't even >> > unserstand where does this message come from. grep didn't help. But this >> > doesn't ma

Re: Multiple potential races on vma->vm_flags

2015-09-24 Thread Oleg Nesterov
On 09/24, Sasha Levin wrote: > > On 09/24/2015 09:11 AM, Oleg Nesterov wrote: > > > > Well, I know absolutely nothing about kasan, to the point I can't even > > unserstand where does this message come from. grep didn't help. But this > > doesn't matter... > > The reason behind this message is that

Re: Multiple potential races on vma->vm_flags

2015-09-24 Thread Sasha Levin
On 09/24/2015 09:11 AM, Oleg Nesterov wrote: > On 09/15, Sasha Levin wrote: >> >> I've modified my tests to stress the exit path of processes with many vmas, >> and hit the following NULL ptr deref (not sure if it's related to the >> original issue): > > I am shy to ask. Looks like I am the only

Re: Multiple potential races on vma->vm_flags

2015-09-24 Thread Oleg Nesterov
On 09/15, Sasha Levin wrote: > > I've modified my tests to stress the exit path of processes with many vmas, > and hit the following NULL ptr deref (not sure if it's related to the > original issue): I am shy to ask. Looks like I am the only stupid one who needs more info... > [1181047.935563] k

Re: Multiple potential races on vma->vm_flags

2015-09-23 Thread Sasha Levin
On 09/23/2015 09:08 AM, Andrey Konovalov wrote: > On Wed, Sep 23, 2015 at 3:39 AM, Hugh Dickins wrote: >> > This is totally untested, and one of you may quickly prove me wrong; >> > but I went in to fix your "Bad page state (mlocked)" by holding pte >> > lock across the down_read_trylock of mmap_s

Re: Multiple potential races on vma->vm_flags

2015-09-23 Thread Davidlohr Bueso
On Wed, 23 Sep 2015, Kirill A. Shutemov wrote: On Tue, Sep 22, 2015 at 06:39:52PM -0700, Hugh Dickins wrote: [...] I'd rather wait to hear whether this appears to work in practice, and whether you agree that it should work in theory, before writing the proper description. I'd love to lose that

Re: Multiple potential races on vma->vm_flags

2015-09-23 Thread Sasha Levin
On 09/15/2015 01:36 PM, Sasha Levin wrote: > On 09/11/2015 09:27 PM, Hugh Dickins wrote: >> > I'm inclined to echo Vlastimil's comment from earlier in the thread: >> > sounds like an overkill, unless we find something more serious than this. > I've modified my tests to stress the exit path of proce

Re: Multiple potential races on vma->vm_flags

2015-09-23 Thread Oleg Nesterov
On 09/11, Kirill A. Shutemov wrote: > > This one is tricky. I *assume* the mm cannot be generally accessible after > mm_users drops to zero, but I'm not entirely sure about it. > procfs? ptrace? Well, all I can say is that proc/ptrace look fine afaics... This is off-topic, but how about the patch

Re: Multiple potential races on vma->vm_flags

2015-09-23 Thread Oleg Nesterov
On 09/23, Oleg Nesterov wrote: > > On 09/11, Kirill A. Shutemov wrote: > > > > This one is tricky. I *assume* the mm cannot be generally accessible after > > mm_users drops to zero, but I'm not entirely sure about it. > > procfs? ptrace? > > Well, all I can say is that proc/ptrace look fine afaics.

Re: Multiple potential races on vma->vm_flags

2015-09-23 Thread Andrey Konovalov
On Wed, Sep 23, 2015 at 3:39 AM, Hugh Dickins wrote: > This is totally untested, and one of you may quickly prove me wrong; > but I went in to fix your "Bad page state (mlocked)" by holding pte > lock across the down_read_trylock of mmap_sem in try_to_unmap_one(), > then couldn't see why it would

Re: Multiple potential races on vma->vm_flags

2015-09-23 Thread Kirill A. Shutemov
On Tue, Sep 22, 2015 at 06:39:52PM -0700, Hugh Dickins wrote: > On Tue, 22 Sep 2015, Andrey Konovalov wrote: > > On Tue, Sep 22, 2015 at 8:54 PM, Hugh Dickins wrote: > > > On Tue, 22 Sep 2015, Andrey Konovalov wrote: > > >> If anybody comes up with a patch to fix the original issue I easily > > >>

Re: Multiple potential races on vma->vm_flags

2015-09-22 Thread Hugh Dickins
On Tue, 22 Sep 2015, Andrey Konovalov wrote: > On Tue, Sep 22, 2015 at 8:54 PM, Hugh Dickins wrote: > > On Tue, 22 Sep 2015, Andrey Konovalov wrote: > >> If anybody comes up with a patch to fix the original issue I easily > >> can test it, since I'm hitting "BUG: Bad page state" in a second when >

Re: Multiple potential races on vma->vm_flags

2015-09-22 Thread Andrey Konovalov
On Tue, Sep 22, 2015 at 8:54 PM, Hugh Dickins wrote: > On Tue, 22 Sep 2015, Andrey Konovalov wrote: >> If anybody comes up with a patch to fix the original issue I easily >> can test it, since I'm hitting "BUG: Bad page state" in a second when >> fuzzing with KTSAN and Trinity. > > This "BUG: Bad

Re: Multiple potential races on vma->vm_flags

2015-09-22 Thread Hugh Dickins
On Tue, 22 Sep 2015, Andrey Konovalov wrote: > If anybody comes up with a patch to fix the original issue I easily > can test it, since I'm hitting "BUG: Bad page state" in a second when > fuzzing with KTSAN and Trinity. This "BUG: Bad page state" sounds more serious, but I cannot track down your

Re: Multiple potential races on vma->vm_flags

2015-09-22 Thread Andrey Konovalov
If anybody comes up with a patch to fix the original issue I easily can test it, since I'm hitting "BUG: Bad page state" in a second when fuzzing with KTSAN and Trinity. On Tue, Sep 15, 2015 at 9:01 PM, Kirill A. Shutemov wrote: > On Tue, Sep 15, 2015 at 01:36:45PM -0400, Sasha Levin wrote: >> On

Re: Multiple potential races on vma->vm_flags

2015-09-15 Thread Kirill A. Shutemov
On Tue, Sep 15, 2015 at 01:36:45PM -0400, Sasha Levin wrote: > On 09/11/2015 09:27 PM, Hugh Dickins wrote: > > I'm inclined to echo Vlastimil's comment from earlier in the thread: > > sounds like an overkill, unless we find something more serious than this. > > I've modified my tests to stress the

Re: Multiple potential races on vma->vm_flags

2015-09-15 Thread Sasha Levin
On 09/11/2015 09:27 PM, Hugh Dickins wrote: > I'm inclined to echo Vlastimil's comment from earlier in the thread: > sounds like an overkill, unless we find something more serious than this. I've modified my tests to stress the exit path of processes with many vmas, and hit the following NULL ptr

Re: Multiple potential races on vma->vm_flags

2015-09-14 Thread Kirill A. Shutemov
On Fri, Sep 11, 2015 at 06:27:14PM -0700, Hugh Dickins wrote: > On Fri, 11 Sep 2015, Kirill A. Shutemov wrote: > > On Thu, Sep 10, 2015 at 03:27:59PM +0200, Andrey Konovalov wrote: > > > Can a vma be shared among a few mm's? > > > > Define "shared". > > > > vma can belong only to one process (mm_

Re: Multiple potential races on vma->vm_flags

2015-09-11 Thread Hugh Dickins
On Fri, 11 Sep 2015, Kirill A. Shutemov wrote: > On Thu, Sep 10, 2015 at 03:27:59PM +0200, Andrey Konovalov wrote: > > Can a vma be shared among a few mm's? > > Define "shared". > > vma can belong only to one process (mm_struct), but it can be accessed > from other process like in rmap case below

Re: Multiple potential races on vma->vm_flags

2015-09-11 Thread Vlastimil Babka
On 09/11/2015 05:29 PM, Vlastimil Babka wrote: On 09/11/2015 12:39 PM, Kirill A. Shutemov wrote: On Thu, Sep 10, 2015 at 03:27:59PM +0200, Andrey Konovalov wrote: Can a vma be shared among a few mm's? Define "shared". vma can belong only to one process (mm_struct), but it can be accessed fro

Re: Multiple potential races on vma->vm_flags

2015-09-11 Thread Vlastimil Babka
On 09/11/2015 12:39 PM, Kirill A. Shutemov wrote: On Thu, Sep 10, 2015 at 03:27:59PM +0200, Andrey Konovalov wrote: Can a vma be shared among a few mm's? Define "shared". vma can belong only to one process (mm_struct), but it can be accessed from other process like in rmap case below. rmap u

Re: Multiple potential races on vma->vm_flags

2015-09-11 Thread Kirill A. Shutemov
On Thu, Sep 10, 2015 at 03:27:59PM +0200, Andrey Konovalov wrote: > Can a vma be shared among a few mm's? Define "shared". vma can belong only to one process (mm_struct), but it can be accessed from other process like in rmap case below. rmap uses anon_vma_lock for anon vma and i_mmap_rwsem for

Re: Multiple potential races on vma->vm_flags

2015-09-10 Thread Andrey Konovalov
Can a vma be shared among a few mm's? If yes, then taking current->mm->mmap_sem to protect vma is not enough. In the first report below both T378 and T398 take current->mm->mmap_sem at mm/mlock.c:650, but they turn out to be different locks (the addresses are different). In the second report T309

Re: Multiple potential races on vma->vm_flags

2015-09-10 Thread Kirill A. Shutemov
On Wed, Sep 09, 2015 at 08:58:26PM -0400, Sasha Levin wrote: > On 09/07/2015 07:40 AM, Kirill A. Shutemov wrote: > > On Sun, Sep 06, 2015 at 03:21:05PM -0400, Sasha Levin wrote: > >> > == > >> > ThreadSanitizer: data-race in munlock_vm

Re: Multiple potential races on vma->vm_flags

2015-09-09 Thread Sasha Levin
On 09/07/2015 07:40 AM, Kirill A. Shutemov wrote: > On Sun, Sep 06, 2015 at 03:21:05PM -0400, Sasha Levin wrote: >> > == >> > ThreadSanitizer: data-race in munlock_vma_pages_range >> > >> > Write of size 8 by thread T378 (K2633, CPU3)

Re: Multiple potential races on vma->vm_flags

2015-09-09 Thread Kirill A. Shutemov
On Wed, Sep 09, 2015 at 05:27:16PM +0200, Vlastimil Babka wrote: > On 09/07/2015 01:40 PM, Kirill A. Shutemov wrote: > >On Sun, Sep 06, 2015 at 03:21:05PM -0400, Sasha Levin wrote: > >>== > >>ThreadSanitizer: data-race in munlock_vma_p

Re: Multiple potential races on vma->vm_flags

2015-09-09 Thread Vlastimil Babka
On 09/07/2015 01:40 PM, Kirill A. Shutemov wrote: On Sun, Sep 06, 2015 at 03:21:05PM -0400, Sasha Levin wrote: == ThreadSanitizer: data-race in munlock_vma_pages_range Write of size 8 by thread T378 (K2633, CPU3): [] munlock_vma_