linux-sh.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 00/11] Fixup page directory freeing
@ 2020-07-17 11:10 Peter Zijlstra
  2020-07-17 11:10 ` [PATCH v2 01/11] asm-generic/tlb: Fix MMU_GATHER_TABLE_FREE Peter Zijlstra
                   ` (11 more replies)
  0 siblings, 12 replies; 14+ messages in thread
From: Peter Zijlstra @ 2020-07-17 11:10 UTC (permalink / raw)
  To: Will Deacon, Aneesh Kumar K.V, Andrew Morton, Nick Piggin,
	Peter Zijlstra
  Cc: linux-arch, linux-sh, linux-mm, linux-kernel, Yoshinori Sato,
	Rich Felker, David S. Miller, Helge Deller, Geert Uytterhoeven,
	Paul Burton, Tony Luck, Richard Henderson, Nick Hu,
	Paul Walmsley, John Paul Adrian Glaubitz, Christoph Hellwig

Hi All,

While fixing a silly bug on SH (patch #1), I realized that even with the
trivial patch to restore prior behaviour, page directory freeing was still
broken.

The thing is, on anything SMP, freeing page directories should observe the
exact same order as normal page freeing:

 1) unhook page/directory
 2) TLB invalidate
 3) free page/directory

Without this any concurrent page-table walk could end up with a Use-after-Free.
This is esp. trivial for anything that has software page-table walkers
(HAVE_FAST_GUP / software TLB fill) or the hardware caches partial page-walks
(ie. caches page directories).

Even on UP this might give issues, since mmu_gather is preemptible these days.
An interrupt or preempted task accessing user pages might stumble into the free
page if the hardware caches page directories.

So I've converted everything to always observe the above order, simply so we
don't have to worry about it.

If however I've been over zealous and your arch/mmu really doesn't need this
and you're offended by this potentially superfluous code, please let me know
and I'll replace the patch with one that adds a comment describing your
rationale for why it is not needed.


v1: https://lkml.kernel.org/r/20191211120713.360281197@infradead.org

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

end of thread, other threads:[~2020-09-21 12:01 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-17 11:10 [PATCH v2 00/11] Fixup page directory freeing Peter Zijlstra
2020-07-17 11:10 ` [PATCH v2 01/11] asm-generic/tlb: Fix MMU_GATHER_TABLE_FREE Peter Zijlstra
2020-09-21 12:01   ` Will Deacon
2020-07-17 11:10 ` [PATCH v2 02/11] sh/tlb: Fix PGTABLE_LEVELS > 2 Peter Zijlstra
2020-07-17 11:10 ` [PATCH v2 03/11] sh/tlb: Fix __pmd_free_tlb() Peter Zijlstra
2020-07-17 11:10 ` [PATCH v2 04/11] sparc32/tlb: Fix __p*_free_tlb() Peter Zijlstra
2020-07-17 11:10 ` [PATCH v2 05/11] parisc/tlb: " Peter Zijlstra
2020-07-17 11:10 ` [PATCH v2 06/11] mips/tlb: " Peter Zijlstra
2020-07-17 11:10 ` [PATCH v2 07/11] ia64/tlb: " Peter Zijlstra
2020-07-17 11:10 ` [PATCH v2 08/11] alpha/tlb: " Peter Zijlstra
2020-07-17 11:10 ` [PATCH v2 09/11] nds32/tlb: " Peter Zijlstra
2020-07-17 11:10 ` [PATCH v2 10/11] riscv/tlb: " Peter Zijlstra
2020-07-17 11:10 ` [PATCH v2 11/11] m68k/tlb: " Peter Zijlstra
2020-07-17 11:22 ` [PATCH v2 00/11] Fixup page directory freeing Peter Zijlstra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).