Skip to content

Commit 1c7873e

Browse files
Hugh Dickinstorvalds
Hugh Dickins
authored andcommitted
mm: lock newly mapped VMA with corrected ordering
Lockdep is certainly right to complain about (&vma->vm_lock->lock){++++}-{3:3}, at: vma_start_write+0x2d/0x3f but task is already holding lock: (&mapping->i_mmap_rwsem){+.+.}-{3:3}, at: mmap_region+0x4dc/0x6db Invert those to the usual ordering. Fixes: 33313a7 ("mm: lock newly mapped VMA which can be modified after it becomes visible") Cc: [email protected] Signed-off-by: Hugh Dickins <[email protected]> Tested-by: Suren Baghdasaryan <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 946c6b5 commit 1c7873e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Diff for: mm/mmap.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -2809,11 +2809,11 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
28092809
if (vma_iter_prealloc(&vmi))
28102810
goto close_and_free_vma;
28112811

2812+
/* Lock the VMA since it is modified after insertion into VMA tree */
2813+
vma_start_write(vma);
28122814
if (vma->vm_file)
28132815
i_mmap_lock_write(vma->vm_file->f_mapping);
28142816

2815-
/* Lock the VMA since it is modified after insertion into VMA tree */
2816-
vma_start_write(vma);
28172817
vma_iter_store(&vmi, vma);
28182818
mm->map_count++;
28192819
if (vma->vm_file) {

0 commit comments

Comments
 (0)