• Pavel Kozlov's avatar
    ARC: mm: fix leakage of memory allocated for PTE · 4fd9df10
    Pavel Kozlov authored
    Since commit d9820ff7 ("ARC: mm: switch pgtable_t back to struct page *")
    a memory leakage problem occurs. Memory allocated for page table entries
    not released during process termination. This issue can be reproduced by
    a small program that allocates a large amount of memory. After several
    runs, you'll see that the amount of free memory has reduced and will
    continue to reduce after each run. All ARC CPUs are effected by this
    issue. The issue was introduced since the kernel stable release v5.15-rc1.
    
    As described in commit d9820ff7 after switch pgtable_t back to struct
    page *, a pointer to "struct page" and appropriate functions are used to
    allocate and free a memory page for PTEs, but the pmd_pgtable macro hasn't
    changed and returns the direct virtual address from the PMD (PGD) entry.
    Than this address used as a parameter in the __pte_free() and as a result
    this function couldn't release memory page allocated for PTEs.
    
    Fix this issue by changing the pmd_pgtable macro and returning pointer to
    struct page.
    
    Fixes: d9820ff7 ("ARC: mm: switch pgtable_t back to struct page *")
    Cc: Mike Rapoport <rppt@kernel.org>
    Cc: <stable@vger.kernel.org> # 5.15.x
    Signed-off-by: default avatarPavel Kozlov <pavel.kozlov@synopsys.com>
    Signed-off-by: default avatarVineet Gupta <vgupta@kernel.org>
    4fd9df10
pgtable-levels.h 5.4 KB