All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] fix memory leak / panic in ioremap huge pages
@ 2018-03-07 18:32 ` Toshi Kani
  0 siblings, 0 replies; 33+ messages in thread
From: Toshi Kani @ 2018-03-07 18:32 UTC (permalink / raw)
  To: mhocko, akpm, tglx, mingo, hpa, bp, catalin.marinas
  Cc: guohanjun, will.deacon, wxf.wang, linux-mm, x86,
	linux-arm-kernel, linux-kernel

On architectures with CONFIG_HAVE_ARCH_HUGE_VMAP set, ioremap()
may create pud/pmd mappings.  Kernel panic was observed on arm64
systems with Cortex-A75 in the following steps as described by
Hanjun Guo. [1]

1. ioremap a 4K size, valid page table will build,
2. iounmap it, pte0 will set to 0;
3. ioremap the same address with 2M size, pgd/pmd is unchanged,
   then set the a new value for pmd;
4. pte0 is leaked;
5. CPU may meet exception because the old pmd is still in TLB,
   which will lead to kernel panic.

This panic is not reproducible on x86.  INVLPG, called from iounmap,
purges all levels of entries associated with purged address on x86.
x86 still has memory leak.

Patch 01 adds new interfaces as stubs, which work as workaround of
this issue.  This patch 01 was leveraged from Hanjun's patch. [1]
Patch 02 fixes the issue on x86 by implementing the interfaces.

[1] https://patchwork.kernel.org/patch/10134581/

---
Toshi Kani (2):
 1/2 mm/vmalloc: Add interfaces to free unused page table
 2/2 x86/mm: implement free pmd/pte page interfaces

---
 arch/arm64/mm/mmu.c           | 10 ++++++++++
 arch/x86/mm/pgtable.c         | 44 +++++++++++++++++++++++++++++++++++++++++++
 include/asm-generic/pgtable.h | 10 ++++++++++
 lib/ioremap.c                 |  6 ++++--
 4 files changed, 68 insertions(+), 2 deletions(-)

^ permalink raw reply	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2018-03-08 23:27 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-07 18:32 [PATCH 0/2] fix memory leak / panic in ioremap huge pages Toshi Kani
2018-03-07 18:32 ` Toshi Kani
2018-03-07 18:32 ` Toshi Kani
2018-03-07 18:32 ` [PATCH 1/2] mm/vmalloc: Add interfaces to free unused page table Toshi Kani
2018-03-07 18:32   ` Toshi Kani
2018-03-07 18:32   ` Toshi Kani
2018-03-07 22:54   ` Andrew Morton
2018-03-07 22:54     ` Andrew Morton
2018-03-07 23:02     ` Kani, Toshi
2018-03-07 23:02       ` Kani, Toshi
2018-03-07 22:55   ` Andrew Morton
2018-03-07 22:55     ` Andrew Morton
2018-03-08  4:00   ` Matthew Wilcox
2018-03-08  4:00     ` Matthew Wilcox
2018-03-08 15:56     ` Kani, Toshi
2018-03-08 15:56       ` Kani, Toshi
2018-03-08 22:07       ` Matthew Wilcox
2018-03-08 22:07         ` Matthew Wilcox
2018-03-08 23:27         ` Kani, Toshi
2018-03-08 23:27           ` Kani, Toshi
2018-03-08  8:08   ` Ingo Molnar
2018-03-08  8:08     ` Ingo Molnar
2018-03-08 18:04   ` Will Deacon
2018-03-08 18:04     ` Will Deacon
2018-03-08 19:30     ` Kani, Toshi
2018-03-08 19:30       ` Kani, Toshi
2018-03-07 18:32 ` [PATCH 2/2] x86/mm: implement free pmd/pte page interfaces Toshi Kani
2018-03-07 18:32   ` Toshi Kani
2018-03-07 18:32   ` Toshi Kani
2018-03-07 23:01   ` Andrew Morton
2018-03-07 23:01     ` Andrew Morton
2018-03-07 23:22     ` Kani, Toshi
2018-03-07 23:22       ` Kani, Toshi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.