summaryrefslogtreecommitdiffstats
path: root/block/blk-pm.c
diff options
context:
space:
mode:
authorJann Horn <jannh@google.com>2023-07-26 23:41:03 +0200
committerLinus Torvalds <torvalds@linux-foundation.org>2023-07-27 11:13:22 -0700
commit657b5146955eba331e01b9a6ae89ce2e716ba306 (patch)
tree28c51d1358cbe6a26e5a284ecf2cdbc59d84b1f0 /block/blk-pm.c
parent0a8db05b571ad5b8d5c8774a004c0424260a90bd (diff)
downloadlinux-stable-657b5146955eba331e01b9a6ae89ce2e716ba306.tar.gz
linux-stable-657b5146955eba331e01b9a6ae89ce2e716ba306.tar.bz2
linux-stable-657b5146955eba331e01b9a6ae89ce2e716ba306.zip
mm: lock_vma_under_rcu() must check vma->anon_vma under vma lock
lock_vma_under_rcu() tries to guarantee that __anon_vma_prepare() can't be called in the VMA-locked page fault path by ensuring that vma->anon_vma is set. However, this check happens before the VMA is locked, which means a concurrent move_vma() can concurrently call unlink_anon_vmas(), which disassociates the VMA's anon_vma. This means we can get UAF in the following scenario: THREAD 1 THREAD 2 ======== ======== <page fault> lock_vma_under_rcu() rcu_read_lock() mas_walk() check vma->anon_vma mremap() syscall move_vma() vma_start_write() unlink_anon_vmas() <syscall end> handle_mm_fault() __handle_mm_fault() handle_pte_fault() do_pte_missing() do_anonymous_page() anon_vma_prepare() __anon_vma_prepare() find_mergeable_anon_vma() mas_walk() [looks up VMA X] munmap() syscall (deletes VMA X) reusable_anon_vma() [called on freed VMA X] This is a security bug if you can hit it, although an attacker would have to win two races at once where the first race window is only a few instructions wide. This patch is based on some previous discussion with Linus Torvalds on the security list. Cc: stable@vger.kernel.org Fixes: 5e31275cc997 ("mm: add per-VMA lock and helper functions to control it") Signed-off-by: Jann Horn <jannh@google.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'block/blk-pm.c')
0 files changed, 0 insertions, 0 deletions