diff options
author | Konstantin Khlebnikov <koct9i@gmail.com> | 2016-02-05 15:36:50 -0800 |
---|---|---|
committer | Sasha Levin <sasha.levin@oracle.com> | 2016-02-15 15:45:36 -0500 |
commit | 4b5eaa857d64ea737c3bed1eb9b3dd201dd2cecf (patch) | |
tree | e6e026ca67512d42e82cba8786bb824165a37d48 /include | |
parent | ff5ecd2953a635bf70101dac550fcb01ced863e9 (diff) |
mm: replace vma_lock_anon_vma with anon_vma_lock_read/write
[ Upstream commit 12352d3cae2cebe18805a91fab34b534d7444231 ]
Sequence vma_lock_anon_vma() - vma_unlock_anon_vma() isn't safe if
anon_vma appeared between lock and unlock. We have to check anon_vma
first or call anon_vma_prepare() to be sure that it's here. There are
only few users of these legacy helpers. Let's get rid of them.
This patch fixes anon_vma lock imbalance in validate_mm(). Write lock
isn't required here, read lock is enough.
And reorders expand_downwards/expand_upwards: security_mmap_addr() and
wrapping-around check don't have to be under anon vma lock.
Link: https://lkml.kernel.org/r/CACT4Y+Y908EjM2z=706dv4rV6dWtxTLK9nFg9_7DhRMLppBo2g@mail.gmail.com
Signed-off-by: Konstantin Khlebnikov <koct9i@gmail.com>
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/rmap.h | 14 |
1 files changed, 0 insertions, 14 deletions
diff --git a/include/linux/rmap.h b/include/linux/rmap.h index c89c53a113a8..6f48ddc4b2b5 100644 --- a/include/linux/rmap.h +++ b/include/linux/rmap.h @@ -105,20 +105,6 @@ static inline void put_anon_vma(struct anon_vma *anon_vma) __put_anon_vma(anon_vma); } -static inline void vma_lock_anon_vma(struct vm_area_struct *vma) -{ - struct anon_vma *anon_vma = vma->anon_vma; - if (anon_vma) - down_write(&anon_vma->root->rwsem); -} - -static inline void vma_unlock_anon_vma(struct vm_area_struct *vma) -{ - struct anon_vma *anon_vma = vma->anon_vma; - if (anon_vma) - up_write(&anon_vma->root->rwsem); -} - static inline void anon_vma_lock_write(struct anon_vma *anon_vma) { down_write(&anon_vma->root->rwsem); |