]> git.baikalelectronics.ru Git - 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)
commite13ba4151031d43ac1316003c321bb759cf18605
tree4ee9ba8685bae5d1719a3158284d0c197c83afde
parent1c3a07090fef1b9cbbcfb1631cd785b6c205ce3b
Fix OOPS in mmap_region() when merging adjacent VM_LOCKED file segments

As of commit 7fb9690d921378ec7e0eed2928c7dda71acf5b6f ("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