提交 ca42b26a 编写于 作者: M Michel Lespinasse 提交者: Linus Torvalds

mm: fix potential anon_vma locking issue in mprotect()

Fix an anon_vma locking issue in the following situation:

- vma has no anon_vma
- next has an anon_vma
- vma is being shrunk / next is being expanded, due to an mprotect call

We need to take next's anon_vma lock to avoid races with rmap users (such
as page migration) while next is being expanded.
Signed-off-by: NMichel Lespinasse <walken@google.com>
Reviewed-by: NAndrea Arcangeli <aarcange@redhat.com>
Acked-by: NHugh Dickins <hughd@google.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 227e4047
......@@ -573,8 +573,12 @@ again: remove_next = 1 + (end > next->vm_end);
*/
if (vma->anon_vma && (importer || start != vma->vm_start)) {
anon_vma = vma->anon_vma;
VM_BUG_ON(adjust_next && next->anon_vma &&
anon_vma != next->anon_vma);
} else if (adjust_next && next->anon_vma)
anon_vma = next->anon_vma;
if (anon_vma)
anon_vma_lock(anon_vma);
}
if (root) {
flush_dcache_mmap_lock(mapping);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册