Skip to content
  • Aneesh Kumar K.V's avatar
    powerpc/mm/hash64: Zero PGD pages on allocation · 288b3732
    Aneesh Kumar K.V authored
    
    [ Upstream commit fc5c2f4a
    
     ]
    
    On powerpc we allocate page table pages from slab caches of different
    sizes. Currently we have a constructor that zeroes out the objects when
    we allocate them for the first time.
    
    We expect the objects to be zeroed out when we free the the object
    back to slab cache. This happens in the unmap path. For hugetlb pages
    we call huge_pte_get_and_clear() to do that.
    
    With the current configuration of page table size, both PUD and PGD
    level tables are allocated from the same slab cache. At the PUD level,
    we use the second half of the table to store the slot information. But
    we never clear that when unmapping.
    
    When such a freed object is then allocated for a PGD page, the second
    half of the page table page will not be zeroed as expected. This
    results in a kernel crash.
    
    Fix it by always clearing PGD pages when they're allocated.
    
    Signed-off-by: default avatarAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
    [mpe: Change log wording and formatting, add whitespace]
    Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
    Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    288b3732