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.

arm64: 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/cf4b847caf390f96a3e3d534dacb2c174e16c154.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>
Acked-by: Will Deacon <will@kernel.org>
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: Yu Zhao <yuzhao@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Qi Zheng and committed by
Andrew Morton
12359c03 0ada8c4d

+4 -6
+4 -6
arch/arm64/include/asm/tlb.h
··· 9 9 #define __ASM_TLB_H 10 10 11 11 #include <linux/pagemap.h> 12 - #include <linux/swap.h> 13 12 14 13 static inline void __tlb_remove_table(void *_table) 15 14 { 16 - free_page_and_swap_cache((struct page *)_table); 15 + struct ptdesc *ptdesc = (struct ptdesc *)_table; 16 + 17 + pagetable_dtor(ptdesc); 18 + pagetable_free(ptdesc); 17 19 } 18 20 19 21 #define tlb_flush tlb_flush ··· 84 82 { 85 83 struct ptdesc *ptdesc = page_ptdesc(pte); 86 84 87 - pagetable_dtor(ptdesc); 88 85 tlb_remove_ptdesc(tlb, ptdesc); 89 86 } 90 87 ··· 93 92 { 94 93 struct ptdesc *ptdesc = virt_to_ptdesc(pmdp); 95 94 96 - pagetable_dtor(ptdesc); 97 95 tlb_remove_ptdesc(tlb, ptdesc); 98 96 } 99 97 #endif ··· 106 106 if (!pgtable_l4_enabled()) 107 107 return; 108 108 109 - pagetable_dtor(ptdesc); 110 109 tlb_remove_ptdesc(tlb, ptdesc); 111 110 } 112 111 #endif ··· 119 120 if (!pgtable_l5_enabled()) 120 121 return; 121 122 122 - pagetable_dtor(ptdesc); 123 123 tlb_remove_ptdesc(tlb, ptdesc); 124 124 } 125 125 #endif