summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDavid Hildenbrand (Arm) <david@kernel.org>2026-10-31 10:39:31 +0100
committerDavid Hildenbrand (Arm) <david@kernel.org>2026-11-02 11:21:28 +0100
commitef694e2d210111cc08c52fd25da9ab130170bfa3 (patch)
tree1654c91b5c00d93be063454d6ee0392c5541d331 /include
parent65a9bf08a3e4d6e58df211ed900c16bafb79b267 (diff)
fork: take mmap_lock before copying mm_struct
dup_mm() copies the parent's mm_struct before dup_mmap() takes the mmap_lock. A concurrent brk() can leave the child with a stale mm->brk and newer heap mappings, causing later brk() requests to fail. Other operations (e.g., PR_SET_MM) on the parent's mm_struct can similarly cause inconsistencies. As a simple and robust fix, grab the parent's mmap_lock earlier. This way we don't need to update individual mm fields in dup_mmap() and keep missing ones. Stop updating the 4 existing members (total_vm, data_vm, exec_vm, stack_vm), as that is now no longer required. Keep releasing the parent's mmap_lock in dup_mmap(), before userfaultfd completion, to avoid moving the userfaultfd handling into the caller. This should get cleaned up later. Move uprobe_start_dup_mmap() to preserve the lock ordering. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Cc: stable@vger.kernel.org Reported-by: Josef Bacik <josef@toxicpanda.com> Reviewed-by: Lorenzo Stoakes (ARM) <ljs@kernel.org> Reviewed-by: Rik van Riel <riel@surriel.com> Reviewed-by: Vlastimil Babka (SUSE) <vbabka@kernel.org> Reviewed-by: Barry Song <baohua@kernel.org> Reviewed-by: Pedro Falcato <pfalcato@suse.de> Reviewed-by: Harry Yoo (Meta) <harry@kernel.org> Reviewed-by: Kiryl Shutsemau (Meta) <kas@kernel.org> Reviewed-by: SJ Park <sj@kernel.org> Tested-by: Muhammad Usama Anjum <usama.anjum@arm.com> Link: https://patch.msgid.link/20261031-fixes_core-v3-2-d6437171ecc3@kernel.org Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Diffstat (limited to 'include')
0 files changed, 0 insertions, 0 deletions