Skip to content

Commit 2407856

Browse files
committed
mm: lock newly mapped VMA with corrected ordering
JIRA: https://issues.redhat.com/browse/RHEL-48221 This patch is a backport of the following upstream commit: commit 1c7873e Author: Hugh Dickins <hughd@google.com> Date: Sat Jul 8 16:04:00 2023 -0700 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: stable@vger.kernel.org Signed-off-by: Hugh Dickins <hughd@google.com> Tested-by: Suren Baghdasaryan <surenb@google.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Rafael Aquini <aquini@redhat.com>
1 parent 70bca13 commit 2407856

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

mm/mmap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2771,11 +2771,11 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
27712771
if (vma_iter_prealloc(&vmi))
27722772
goto close_and_free_vma;
27732773

2774+
/* Lock the VMA since it is modified after insertion into VMA tree */
2775+
vma_start_write(vma);
27742776
if (vma->vm_file)
27752777
i_mmap_lock_write(vma->vm_file->f_mapping);
27762778

2777-
/* Lock the VMA since it is modified after insertion into VMA tree */
2778-
vma_start_write(vma);
27792779
vma_iter_store(&vmi, vma);
27802780
mm->map_count++;
27812781
if (vma->vm_file) {

0 commit comments

Comments
 (0)