]> git.baikalelectronics.ru Git - kernel.git/commit
powerpc: Fix PTE page address mismatch in pgtable ctor/dtor
authorHong H. Pham <hong.pham@windriver.com>
Sat, 7 Dec 2013 14:06:33 +0000 (09:06 -0500)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Tue, 10 Dec 2013 00:25:05 +0000 (11:25 +1100)
commitb964c5eecd17bf9a3a90080e1ff9213acf7cdaae
tree0c8a9b60e17be65256cbf13bcb27453c5e570329
parent4d1b2f4faa2e0053b4d1bfa1265ef898879c757d
powerpc: Fix PTE page address mismatch in pgtable ctor/dtor

In pte_alloc_one(), pgtable_page_ctor() is passed an address that has
not been converted by page_address() to the newly allocated PTE page.

When the PTE is freed, __pte_free_tlb() calls pgtable_page_dtor()
with an address to the PTE page that has been converted by page_address().
The mismatch in the PTE's page address causes pgtable_page_dtor() to access
invalid memory, so resources for that PTE (such as the page lock) is not
properly cleaned up.

On PPC32, only SMP kernels are affected.

On PPC64, only SMP kernels with 4K page size are affected.

This bug was introduced by commit 46ad9a4ee8dd1e229f48b5b04abf6b9a716b38b5
"powerpc: Move the pte free routines from common header".

On a preempt-rt kernel, a spinlock is dynamically allocated for each
PTE in pgtable_page_ctor().  When the PTE is freed, calling
pgtable_page_dtor() with a mismatched page address causes a memory leak,
as the pointer to the PTE's spinlock is bogus.

On mainline, there isn't any immediately obvious symptoms, but the
problem still exists here.

Fixes: 46ad9a4ee8dd1e22 "powerpc: Move the pte free routes from common header"
Cc: Paul Mackerras <paulus@samba.org>
Cc: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: linux-stable <stable@vger.kernel.org> # v3.10+
Signed-off-by: Hong H. Pham <hong.pham@windriver.com>
Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
arch/powerpc/include/asm/pgalloc-32.h
arch/powerpc/include/asm/pgalloc-64.h