Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

arm: pgtable: move pagetable_dtor() to __tlb_remove_table()

Move pagetable_dtor() to __tlb_remove_table(), so that ptlock and page
table pages can be freed together (regardless of whether RCU is used).
This prevents the use-after-free problem where the ptlock is freed
immediately but the page table pages is freed later via RCU.

Page tables shouldn't have swap cache, so use pagetable_free() instead of
free_page_and_swap_cache() to free page table pages.

Link: https://lkml.kernel.org/r/327b4b8990729edd4ce97d9d5acbdaff2d9fa1d1.1736317725.git.zhengqi.arch@bytedance.com
Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com>
Suggested-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Kevin Brodsky <kevin.brodsky@arm.com>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Alexandre Ghiti <alex@ghiti.fr>
Cc: Alexandre Ghiti <alexghiti@rivosinc.com>
Cc: Andreas Larsson <andreas@gaisler.com>
Cc: Aneesh Kumar K.V (Arm) <aneesh.kumar@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Jann Horn <jannh@google.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Mike Rapoport (Microsoft) <rppt@kernel.org>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vishal Moola (Oracle) <vishal.moola@gmail.com>
Cc: Will Deacon <will@kernel.org>
Cc: Yu Zhao <yuzhao@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Qi Zheng and committed by
Andrew Morton
0ada8c4d db6b435d

+6 -3
+6 -3
arch/arm/include/asm/tlb.h
··· 26 26 27 27 #else /* !CONFIG_MMU */ 28 28 29 - #include <linux/swap.h> 30 29 #include <asm/tlbflush.h> 31 30 32 31 static inline void __tlb_remove_table(void *_table) 33 32 { 34 - free_page_and_swap_cache((struct page *)_table); 33 + struct ptdesc *ptdesc = (struct ptdesc *)_table; 34 + 35 + pagetable_dtor(ptdesc); 36 + pagetable_free(ptdesc); 35 37 } 36 38 37 39 #include <asm-generic/tlb.h> ··· 43 41 { 44 42 struct ptdesc *ptdesc = page_ptdesc(pte); 45 43 44 + #ifndef CONFIG_MMU_GATHER_TABLE_FREE 46 45 pagetable_dtor(ptdesc); 46 + #endif 47 47 48 48 #ifndef CONFIG_ARM_LPAE 49 49 /* ··· 65 61 #ifdef CONFIG_ARM_LPAE 66 62 struct ptdesc *ptdesc = virt_to_ptdesc(pmdp); 67 63 68 - pagetable_dtor(ptdesc); 69 64 tlb_remove_ptdesc(tlb, ptdesc); 70 65 #endif 71 66 }