diff options
author | Hugh Dickins <hughd@google.com> | 2023-07-08 16:04:00 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-07-11 06:31:04 +0200 |
commit | 18822d84fd0931825e9640d757a47a93df1c97bb (patch) | |
tree | 4e6685c2c68fbe16a015a2f2e6cd5c787e7c7ef3 /mm | |
parent | 406815be903b5d7edeffff9594eabf0db2035fe1 (diff) | |
download | linux-stable-18822d84fd0931825e9640d757a47a93df1c97bb.tar.gz linux-stable-18822d84fd0931825e9640d757a47a93df1c97bb.tar.bz2 linux-stable-18822d84fd0931825e9640d757a47a93df1c97bb.zip |
mm: lock newly mapped VMA with corrected ordering
commit 1c7873e3364570ec89343ff4877e0f27a7b21a61 upstream.
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: 33313a747e81 ("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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/mmap.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/mm/mmap.c b/mm/mmap.c index 74e96a144b44..30bf7772d4ac 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2801,11 +2801,11 @@ cannot_expand: if (vma_iter_prealloc(&vmi)) goto close_and_free_vma; + /* Lock the VMA since it is modified after insertion into VMA tree */ + vma_start_write(vma); if (vma->vm_file) i_mmap_lock_write(vma->vm_file->f_mapping); - /* Lock the VMA since it is modified after insertion into VMA tree */ - vma_start_write(vma); vma_iter_store(&vmi, vma); mm->map_count++; if (vma->vm_file) { |