From: Suren Baghdasaryan Date: Mon, 27 Feb 2023 17:36:19 +0000 (-0800) Subject: kernel/fork: assert no VMA readers during its destruction X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=1d8fb11a07e3a2a96681d578d2e7eb3e6d574400;p=users%2Fjedix%2Flinux-maple.git 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 Signed-off-by: Andrew Morton --- diff --git a/kernel/fork.c b/kernel/fork.c index b79ba1d73a41..6944f4eeb4a3 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