linux/arch
Naoya Horiguchi cbef8478be mm/hugetlb: pmd_huge() returns true for non-present hugepage
Migrating hugepages and hwpoisoned hugepages are considered as non-present
hugepages, and they are referenced via migration entries and hwpoison
entries in their page table slots.

This behavior causes race condition because pmd_huge() doesn't tell
non-huge pages from migrating/hwpoisoned hugepages.  follow_page_mask() is
one example where the kernel would call follow_page_pte() for such
hugepage while this function is supposed to handle only normal pages.

To avoid this, this patch makes pmd_huge() return true when pmd_none() is
true *and* pmd_present() is false.  We don't have to worry about mixing up
non-present pmd entry with normal pmd (pointing to leaf level pte entry)
because pmd_present() is true in normal pmd.

The same race condition could happen in (x86-specific) gup_pmd_range(),
where this patch simply adds pmd_present() check instead of pmd_huge().
This is because gup_pmd_range() is fast path.  If we have non-present
hugepage in this function, we will go into gup_huge_pmd(), then return 0
at flag mask check, and finally fall back to the slow path.

Fixes: 290408d4a2 ("hugetlb: hugepage migration core")
Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: James Hogan <james.hogan@imgtec.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Mel Gorman <mel@csn.ul.ie>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: Rik van Riel <riel@redhat.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Luiz Capitulino <lcapitulino@redhat.com>
Cc: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
Cc: Lee Schermerhorn <lee.schermerhorn@hp.com>
Cc: Steve Capper <steve.capper@linaro.org>
Cc: <stable@vger.kernel.org>	[2.6.36+]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-02-11 17:06:01 -08:00
..
alpha alpha: drop _PAGE_FILE and pte_file()-related helpers 2015-02-10 14:30:31 -08:00
arc arc: drop _PAGE_FILE and pte_file()-related helpers 2015-02-10 14:30:31 -08:00
arm mm/hugetlb: reduce arch dependent code around follow_huge_* 2015-02-11 17:06:01 -08:00
arm64 mm/hugetlb: reduce arch dependent code around follow_huge_* 2015-02-11 17:06:01 -08:00
avr32 avr32: drop _PAGE_FILE and pte_file()-related helpers 2015-02-10 14:30:31 -08:00
blackfin Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial 2015-02-10 18:57:15 -08:00
c6x c6x: drop pte_file() 2015-02-10 14:30:32 -08:00
cris cris: drop _PAGE_FILE and pte_file()-related helpers 2015-02-10 14:30:32 -08:00
frv Merge branch 'akpm' (patches from Andrew) 2015-02-10 16:45:56 -08:00
hexagon hexagon: drop _PAGE_FILE and pte_file()-related helpers 2015-02-10 14:30:32 -08:00
ia64 mm/hugetlb: reduce arch dependent code around follow_huge_* 2015-02-11 17:06:01 -08:00
m32r m32r: drop _PAGE_FILE and pte_file()-related helpers 2015-02-10 14:30:32 -08:00
m68k Merge branch 'akpm' (patches from Andrew) 2015-02-10 16:45:56 -08:00
metag mm/hugetlb: reduce arch dependent code around follow_huge_* 2015-02-11 17:06:01 -08:00
microblaze Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2015-02-10 20:01:30 -08:00
mips mm/hugetlb: reduce arch dependent code around follow_huge_* 2015-02-11 17:06:01 -08:00
mn10300 Merge branch 'akpm' (patches from Andrew) 2015-02-10 16:45:56 -08:00
nios2 nios2: drop _PAGE_FILE and pte_file()-related helpers 2015-02-10 14:30:32 -08:00
openrisc openrisc: drop _PAGE_FILE and pte_file()-related helpers 2015-02-10 14:30:33 -08:00
parisc parisc: drop _PAGE_FILE and pte_file()-related helpers 2015-02-10 14:30:33 -08:00
powerpc mm/hugetlb: reduce arch dependent code around follow_huge_* 2015-02-11 17:06:01 -08:00
s390 mm/hugetlb: reduce arch dependent code around follow_huge_* 2015-02-11 17:06:01 -08:00
score score: drop _PAGE_FILE and pte_file()-related helpers 2015-02-10 14:30:33 -08:00
sh mm/hugetlb: reduce arch dependent code around follow_huge_* 2015-02-11 17:06:01 -08:00
sparc mm/hugetlb: reduce arch dependent code around follow_huge_* 2015-02-11 17:06:01 -08:00
tile mm/hugetlb: reduce arch dependent code around follow_huge_* 2015-02-11 17:06:01 -08:00
um um: drop _PAGE_FILE and pte_file()-related helpers 2015-02-10 14:30:33 -08:00
unicore32 unicore32: drop pte_file()-related helpers 2015-02-10 14:30:33 -08:00
x86 mm/hugetlb: pmd_huge() returns true for non-present hugepage 2015-02-11 17:06:01 -08:00
xtensa xtensa: drop _PAGE_FILE and pte_file()-related helpers 2015-02-10 14:30:33 -08:00
.gitignore
Kconfig