]> git.baikalelectronics.ru Git - kernel.git/commit
ARC: mm: fix leakage of memory allocated for PTE
authorPavel Kozlov <pavel.kozlov@synopsys.com>
Mon, 17 Oct 2022 16:11:27 +0000 (20:11 +0400)
committerVineet Gupta <vgupta@kernel.org>
Mon, 17 Oct 2022 23:32:12 +0000 (16:32 -0700)
commit2d5d1947ec31e8305caa75550e2980b935a02f3d
tree58c63a1ea7c2e13e9a5bb2c8a3885897cb1ff83d
parent52bf51267f0e4bf3f949c3b4bb3797dea6b7b366
ARC: mm: fix leakage of memory allocated for PTE

Since commit 15c1d9b ("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 15c1d9b 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: 15c1d9b6849b ("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: Pavel Kozlov <pavel.kozlov@synopsys.com>
Signed-off-by: Vineet Gupta <vgupta@kernel.org>
arch/arc/include/asm/pgtable-levels.h