]> git.baikalelectronics.ru Git - kernel.git/commit
arm64: Fix THP protection change logic
authorSteve Capper <steve.capper@linaro.org>
Thu, 1 Oct 2015 12:06:07 +0000 (13:06 +0100)
committerCatalin Marinas <catalin.marinas@arm.com>
Thu, 1 Oct 2015 17:02:21 +0000 (18:02 +0100)
commitfb58ff26c9359e0ede2871ba3f8632079ca6ac23
tree89342e38161dc6e6d2b6c13df33c559e3e437cb6
parent755b54c2d7664b903bfb45b7d15cb67261530d08
arm64: Fix THP protection change logic

5b2342f ("arm64: enable PTE type bit in the mask for pte_modify") fixes
a problem whereby a large block of PROT_NONE mapped memory is
incorrectly mapped as block descriptors when mprotect is called.

Unfortunately, a subtle bug was introduced by this fix to the THP logic.

If one mmaps a large block of memory, then faults it such that it is
collapsed into THPs; resulting calls to mprotect on this area of memory
will lead to incorrect table descriptors being written instead of block
descriptors. This is because pmd_modify calls pte_modify which is now
allowed to modify the type of the page table entry.

This patch reverts commit 5b2342fbbcb8b3a2ed9796c85430430c4d4034a0, and
fixes the problem it was trying to address by adjusting PAGE_NONE to
represent a table entry. Thus no change in pte type is required when
moving from PROT_NONE to a different protection.

Fixes: 5b2342fbbcb8 ("arm64: enable PTE type bit in the mask for pte_modify")
Cc: <stable@vger.kernel.org> # 4.0+
Cc: Feng Kan <fkan@apm.com>
Reported-by: Ganapatrao Kulkarni <Ganapatrao.Kulkarni@caviumnetworks.com>
Tested-by: Ganapatrao Kulkarni <gkulkarni@caviumnetworks.com>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Steve Capper <steve.capper@linaro.org>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
arch/arm64/include/asm/pgtable.h