diff options
author | Suren Baghdasaryan <surenb@google.com> | 2023-02-27 18:36:19 +0100 |
---|---|---|
committer | Andrew Morton <akpm@linux-foundation.org> | 2023-04-06 05:02:59 +0200 |
commit | f2e13784c16a98e269b3111ac02ae44446dd589c (patch) | |
tree | 9749cbfbb46025ed2e87f4017d0a2928046cbf13 /kernel/fork.c | |
parent | mm: conditionally write-lock VMA in free_pgtables (diff) | |
download | linux-f2e13784c16a98e269b3111ac02ae44446dd589c.tar.xz linux-f2e13784c16a98e269b3111ac02ae44446dd589c.zip |
kernel/fork: assert no VMA readers during its destruction
Assert there are no holders of VMA lock for reading when it is about to be
destroyed.
Link: https://lkml.kernel.org/r/20230227173632.3292573-21-surenb@google.com
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'kernel/fork.c')
-rw-r--r-- | kernel/fork.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/kernel/fork.c b/kernel/fork.c index 0907776d8ed4..76fcc08984d4 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -491,6 +491,9 @@ static void vm_area_free_rcu_cb(struct rcu_head *head) { struct vm_area_struct *vma = container_of(head, struct vm_area_struct, vm_rcu); + + /* The vma should not be locked while being destroyed. */ + VM_BUG_ON_VMA(rwsem_is_locked(&vma->lock), vma); __vm_area_free(vma); } #endif |