mm: highmem: don't treat PKMAP_ADDR(LAST_PKMAP) as a highmem address
authorWill Deacon <will.deacon@arm.com>
Fri, 16 Nov 2012 22:15:00 +0000 (14:15 -0800)
committerBen Hutchings <ben@decadent.org.uk>
Fri, 11 Jul 2014 12:33:33 +0000 (13:33 +0100)
commit0efda016ac2fb3db57ee19f5df746eca4250955d
treeb645155c09c88ae2515fddc8a20cbbbe526bf04a
parent6b3965a54357210adb2c5cf15a42083ef31aab56
mm: highmem: don't treat PKMAP_ADDR(LAST_PKMAP) as a highmem address

commit 498c2280212327858e521e9d21345d4cc2637f54 upstream.

kmap_to_page returns the corresponding struct page for a virtual address
of an arbitrary mapping.  This works by checking whether the address
falls in the pkmap region and using the pkmap page tables instead of the
linear mapping if appropriate.

Unfortunately, the bounds checking means that PKMAP_ADDR(LAST_PKMAP) is
incorrectly treated as a highmem address and we can end up walking off
the end of pkmap_page_table and subsequently passing junk to pte_page.

This patch fixes the bound check to stay within the pkmap tables.

Signed-off-by: Will Deacon <will.deacon@arm.com>
Cc: Mel Gorman <mgorman@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
mm/highmem.c