[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150923153857.GA20233@redhat.com>
Date: Wed, 23 Sep 2015 17:38:57 +0200
From: Oleg Nesterov <oleg@...hat.com>
To: "Kirill A. Shutemov" <kirill@...temov.name>
Cc: Andrey Konovalov <andreyknvl@...gle.com>,
Sasha Levin <sasha.levin@...cle.com>,
Rik van Riel <riel@...hat.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Dmitry Vyukov <dvyukov@...gle.com>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org, Vlastimil Babka <vbabka@...e.cz>,
Hugh Dickins <hughd@...gle.com>
Subject: Re: Multiple potential races on vma->vm_flags
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...
>
> This is off-topic, but how about the patch below? Different threads can
> expand different vma's at the same time under read_lock(mmap_sem), so
> vma_lock_anon_vma() can't help to serialize "locked_vm += grow".
perhaps vm_stat_account() should be moved too, but total_vm/etc is less
important.
Or I missed something?
Oleg.
> --- x/mm/mmap.c
> +++ x/mm/mmap.c
> @@ -2146,9 +2146,6 @@ static int acct_stack_growth(struct vm_a
> if (security_vm_enough_memory_mm(mm, grow))
> return -ENOMEM;
>
> - /* Ok, everything looks good - let it rip */
> - if (vma->vm_flags & VM_LOCKED)
> - mm->locked_vm += grow;
> vm_stat_account(mm, vma->vm_flags, vma->vm_file, grow);
> return 0;
> }
> @@ -2210,6 +2207,8 @@ int expand_upwards(struct vm_area_struct
> * against concurrent vma expansions.
> */
> spin_lock(&vma->vm_mm->page_table_lock);
> + if (vma->vm_flags & VM_LOCKED)
> + mm->locked_vm += grow;
> anon_vma_interval_tree_pre_update_vma(vma);
> vma->vm_end = address;
> anon_vma_interval_tree_post_update_vma(vma);
> @@ -2281,6 +2280,8 @@ int expand_downwards(struct vm_area_stru
> * against concurrent vma expansions.
> */
> spin_lock(&vma->vm_mm->page_table_lock);
> + if (vma->vm_flags & VM_LOCKED)
> + mm->locked_vm += grow;
> anon_vma_interval_tree_pre_update_vma(vma);
> vma->vm_start = address;
> vma->vm_pgoff -= grow;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists