]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commit
Fix OOPS in mmap_region() when merging adjacent VM_LOCKED file segments
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 30 Jan 2009 01:46:42 +0000 (17:46 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 30 Jan 2009 01:46:42 +0000 (17:46 -0800)
commitde33c8db5910cda599899dd431cc30d7c1018cbf
tree4ee9ba8685bae5d1719a3158284d0c197c83afde
parent18e352e4a73465349711a9324767e1b2453383e2
Fix OOPS in mmap_region() when merging adjacent VM_LOCKED file segments

As of commit ba470de43188cdbff795b5da43a1474523c6c2fb ("map: handle
mlocked pages during map, remap, unmap") we now use the 'vma' variable
at the end of mmap_region() to handle the page-in of newly mapped
mlocked pages.

However, if we merged adjacent vma's together, the vma we're using may
be stale.  We historically consciously avoided using it after the merge
operation, but that got overlooked when redoing the locked page
handling.

This commit simplifies mmap_region() by doing any vma merges early,
avoiding the issue entirely, and 'vma' will always be valid.  As pointed
out by Hugh Dickins, this depends on any drivers that change the page
offset of flags to have set one of the VM_SPECIAL bits (so that they
cannot trigger the early merge logic), but that's true in general.

Reported-and-tested-by: Maksim Yevmenkin <maksim.yevmenkin@gmail.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
Cc: Nick Piggin <npiggin@suse.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Hugh Dickins <hugh@veritas.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/mmap.c