mm/madvise: use mmap_sem lock from passed mm_struct

Use the mmap_sem lock from passed 'mm' rather than the 'current' as it
is required because of the patchset[1]. The commit f4fa8d937e ("mm:
madvise: fix vma user-after-free") changed the 'mmap_sem' to use from
'current' instead of 'mm' context. Revert it.

Link: [1] https://patchwork.kernel.org/project/linux-mm/patch/20200302193630.68771-2-minchan@kernel.org/.

Change-Id: Ifc9deb2a5f0775c2bc97c85db3584f61fa3a43ae
Signed-off-by: Charan Teja Reddy <charante@codeaurora.org>
Signed-off-by: Srinivasarao P <spathi@codeaurora.org>
This commit is contained in:
Charan Teja Reddy 2021-09-20 11:03:53 +05:30 • committed by Srinivasarao P
commit 6f65360b49

View file

@ -298,7 +298,7 @@ static long madvise_willneed(struct vm_area_struct *vma,
get_file(file);
offset = (loff_t)(start - vma->vm_start)
+ ((loff_t)vma->vm_pgoff << PAGE_SHIFT);
up_read(&current->mm->mmap_sem);
up_read(&mm->mmap_sem);
vfs_fadvise(file, offset, end - start, POSIX_FADV_WILLNEED);
fput(file);
down_read(&mm->mmap_sem);