Message ID | 955162bfbbcd9fbb3b074e1fe2aef4f64b61d6f9.1734945104.git.zhengqi.arch@bytedance.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B5646E7718B for <linux-mm@archiver.kernel.org>; Mon, 23 Dec 2024 09:44:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 201BC6B00A1; Mon, 23 Dec 2024 04:44:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1B0E06B00A0; Mon, 23 Dec 2024 04:44:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 079F46B00A1; Mon, 23 Dec 2024 04:44:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id DD21D6B009F for <linux-mm@kvack.org>; Mon, 23 Dec 2024 04:44:48 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 9098080FF7 for <linux-mm@kvack.org>; Mon, 23 Dec 2024 09:44:48 +0000 (UTC) X-FDA: 82925738364.24.D4E5B43 Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) by imf02.hostedemail.com (Postfix) with ESMTP id 4E2C38000E for <linux-mm@kvack.org>; Mon, 23 Dec 2024 09:43:34 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=kt7P59zg; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf02.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.210.179 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734947051; a=rsa-sha256; cv=none; b=XN51c5+AvH9FROu2mGac6U+pEeyV6uZGJHGziqSqtD6y2cJ9RLaLdoA70e/Gy59u1YwjDI fRr1zk9+2/13X/UFoxjinMW3b21cdaFvU/liaVuqdNd6sscQM7aWNI4oW3mKllg0brLUXP OgryTRMN3u3LbkByOUNEEbqyvic9tcc= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=kt7P59zg; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf02.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.210.179 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734947051; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=qA0mhWnXo6upWemI3POPEc6VJyAkyxFJggkOB6WNq2k=; b=7hhKEcBRevZhCyWJwIEQjiHnCWYbxMQSgHdeHGc40Y1MavnTsFiCdg9R8calJyLvPFn6qj HeUuAq5Hot8aGQ4pphSu+Xq/NC0kG09ZHDC2DC59Zq8AE9A6Y6SAuNyDzsfr392hkfmeC2 BiHSj1xjYsMvIezrNYjQmBlFjWnSWTM= Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-72909c459c4so3085607b3a.1 for <linux-mm@kvack.org>; Mon, 23 Dec 2024 01:44:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1734947085; x=1735551885; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qA0mhWnXo6upWemI3POPEc6VJyAkyxFJggkOB6WNq2k=; b=kt7P59zgI/Svyo/DsYyuln1aLVBFIe8ZZVWjFw5i38n84v6Xld44IupjGeS5Wckb10 /y5Csq1RfaG/ZhQvX9UW8nQ53Dffcg7XpUdZHErJu62kho1yWlJseETVULepRKb6juYS 53ShYvn89E4uatohj8Pzn6AJUYPDkMZNi+2r+0eQq1W0P1LqpihJrmXCJcVS+gie4IWQ hKZnKnJuD97qBQpls+TQvPpCIxh2G5SKfoqsOVMY9lPTBNzTwx4pX3K06yYXbXdZSN6b 9mMKHSWaPhaHwyzFoQuup7IlRh2SWKmvyROTcYZdxakH172QpYXdl+dc6g1a7IpbErJF R9bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734947085; x=1735551885; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qA0mhWnXo6upWemI3POPEc6VJyAkyxFJggkOB6WNq2k=; b=BuZ+dg2EWyAyZxGiqHghs62LmfUv2TNrlX+MVtvi5FYR9ZE0pcvGm9BukA3lMR2xDj XagmEIMieCWrOp7c12MSUZjEiN7zEy/NKVU2hddCcd5qkqJGiOkE0fSkmHFlFDulDVRW Q5fug6yrWq8QYq8Y8Em3biXt8G+7n4nS6//6YcKPFvl6/dqxQnr/3gn3GlPQ99+JV5Zs 8xthHEcQYqC3j4e5D4uk66HSsRAyyIouleeiUDBWbdohykQ+k8ao+T14eLjKOkvndV23 EZwgqZ0a6yMMYKPVlUWZ76Z/upxGnykhPIqS3/0tbn/jAids4vptznn37CO+CpHtRgXU uQCA== X-Gm-Message-State: AOJu0Yzm53dKXUni7vcRHBTjaV6lbjJZ9xsA5VkilKYjhukp1WqBGRnm IpVb6NlfOgyM3EMNR5ETxUj7KuWSHWPOJ4XaT1BJ4qByquCCjCw3oI0seOKKN0c= X-Gm-Gg: ASbGnctR5DLn+WVUqtfDc41mOZg0UXYmADFNY3hiw9xHsNTX8oiEr+CkJqKQ++kvROH /qPUcVq/nTECZqT5NY18uJOtY9F16HjEt212NrZOeWmOedydXMPUftiVHRcZ7j6pp2R3U/CEpTq k7Nle4gxGAGMDsRrELuyFpBrgwDPPTFUaczpnGlEwihMaF+n1sbzWtNrwVFOpAVlT1lezbPivVf Mt02PH8eHqT+oZ53nWrkcxvJZdtCdnvy/9kKmZoMtZeFe/0A67F3vrWtoe9Za2WqKApC7TBi+t2 kYeV4cdWWmfcwJd0FFRvlg== X-Google-Smtp-Source: AGHT+IEwnxNRxjpY566VNLJW6lRIrSoOOApqv/9DKS3yUbVNE+/391+nOnqyFIwO+T3gR5XgQach6A== X-Received: by 2002:a05:6a00:330b:b0:728:e382:5f14 with SMTP id d2e1a72fcca58-72abdd7bae3mr14443469b3a.9.1734947085429; Mon, 23 Dec 2024 01:44:45 -0800 (PST) Received: from C02DW0BEMD6R.bytedance.net ([203.208.167.150]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8486c6sm7468309b3a.85.2024.12.23.01.44.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Dec 2024 01:44:45 -0800 (PST) From: Qi Zheng <zhengqi.arch@bytedance.com> To: peterz@infradead.org, agordeev@linux.ibm.com, kevin.brodsky@arm.com, tglx@linutronix.de, david@redhat.com, jannh@google.com, hughd@google.com, yuzhao@google.com, willy@infradead.org, muchun.song@linux.dev, vbabka@kernel.org, lorenzo.stoakes@oracle.com, akpm@linux-foundation.org, rientjes@google.com, vishal.moola@gmail.com, arnd@arndb.de, will@kernel.org, aneesh.kumar@kernel.org, npiggin@gmail.com, dave.hansen@linux.intel.com, rppt@kernel.org, ryan.roberts@arm.com Cc: linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org, linux-arch@vger.kernel.org, linux-csky@vger.kernel.org, linux-hexagon@vger.kernel.org, loongarch@lists.linux.dev, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-openrisc@vger.kernel.org, linux-sh@vger.kernel.org, linux-um@lists.infradead.org, Qi Zheng <zhengqi.arch@bytedance.com> Subject: [PATCH v3 08/17] arm: pgtable: move pagetable_dtor() to __tlb_remove_table() Date: Mon, 23 Dec 2024 17:40:54 +0800 Message-Id: <955162bfbbcd9fbb3b074e1fe2aef4f64b61d6f9.1734945104.git.zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <cover.1734945104.git.zhengqi.arch@bytedance.com> References: <cover.1734945104.git.zhengqi.arch@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 4E2C38000E X-Stat-Signature: 79bg58jnrazh4kfweqyhpnerawkg6zau X-Rspam-User: X-HE-Tag: 1734947014-501639 X-HE-Meta: U2FsdGVkX1/TbFYCtNhGXEjezx6JAsXhrWR4nqZhWn3Xy5DkClRcvwUSJVFgw+fPqLVwKz8basAuT4d34hL8k/lshslqS28Y4bhViuMtOSDOYIihZDOTeZWRkSe/TtdjCYZlcBL7+WKFpp2/+f49sm3m6QDu44TVl3euKSA29QEzSHAz4d+YQgI3fPlETwQOVPGadAWDRMmDgVoYUH6Vl45lveFJAjoKQRynMRG6I0RN3U/ARNfurbFHnxGMuLKKoNpEN4ePUw0FLg4AkgJLcQXjlEkG/9USrH9FEcEUS32Mx4eNk0HY9jS5E6wMpGKD9EZWx87RM6NK/go/JdGi0eais/Vj3RXiRTstKvyKKtt5s6TtQZMmZghddhKfLH8VVGCE6k+UvscKJjA7B2dYuRvzZbPkpNjoPilkzmnE0j+pns28BD1nNy6tBk879pJg9tYCE0H0Cle/W9dhx86Tak7h3AHXXKXWGvaDnWaj1BACRpz80uwgMBcxayyn/NMTqwll0+504zWJkB0UhOgm2qBIn/dNpD6VkdhSOj8iV1m3Q4zV+4bEureJVANUDrE0tMFPPrYYd0P0UzkMd1Oy7HubMjmirffCuKYCQgYjK4dYw/j7m3FgYQdwh2fzc4gc0e83Kmbmtvsg6TVL34wh90DxNgf/0bau5KSqqn+oIKxou/Zr10h/OkMMKRaxYT7JTcjzNlLt6ADNO1fMIYaN8mE07+yihVtcQ9E/qJ4bF2GGvamPvd1J0zWzcl95bZYX8nYfk14GthYTvRwXnKWqIPCoYgMuaGZwjLevPI4BYbzkMXB/O0xgW9BoIhnxamUqgAfEGSyrdQiC7Q9zWrGaZxSn5lUP1SleZL2VOL6Rr2aDZc0nmr0CBRRCRiS43FbYwYz/UPIb2jfZcMTFNbo1xlE+N8fY3LPxoO22ZM4tLgatAVzWQi9quEPGOPNYC9Bcn7o/B7CgzPhwJrMto+O ETv11EzW fcKClN/SUXYboOCkp/g41YenE/oG8vqZrJCvQShox/KWtV0OVgnWwH6D7R0YEhU8WHShretTlONMIfdn4+jZz/Z4Q4nhqYcL/en+j4YnmYxbpVRAhjG9x9OE7bI4bU4GFazPuMxJlrZo+xdeF8/DToNUBgQEHbxeVPco0iD+TZGu9gbiqSSxg7KVeodUD//PeM6psEuYd4BzIUjJ01utybc2+xi9OdgfiR57SrM7WoDgLuSvIFP6xrBLEUx8+oZKNx8mymtvPuxpMm5tnzksTsDcMQocG9WqWHEv/Xwd3zFMMxjbwhcxNBmVhjkSKt2a+8f/niwtlJdiBPcuepN2/ShiBLPjPVTqjdVruerYiO5pttjDGHvXV3ZqbpRwWQPY4L+dSSPSxXTjMLb6acCDSKDs5moZK/e/PcZmnLQUJ7dMSraTrnqK+gnMF0WvXdEtLsAenhPkqg2Z6N1Cd5JjFrJrFw4B1enw0SlxLNYtLwgIaG+4= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
move pagetable_*_dtor() to __tlb_remove_table()
|
expand
|
diff --git a/arch/arm/include/asm/tlb.h b/arch/arm/include/asm/tlb.h index ef79bf1e8563f..264ab635e807a 100644 --- a/arch/arm/include/asm/tlb.h +++ b/arch/arm/include/asm/tlb.h @@ -26,12 +26,14 @@ #else /* !CONFIG_MMU */ -#include <linux/swap.h> #include <asm/tlbflush.h> static inline void __tlb_remove_table(void *_table) { - free_page_and_swap_cache((struct page *)_table); + struct ptdesc *ptdesc = (struct ptdesc *)_table; + + pagetable_dtor(ptdesc); + pagetable_free(ptdesc); } #include <asm-generic/tlb.h> @@ -41,8 +43,6 @@ __pte_free_tlb(struct mmu_gather *tlb, pgtable_t pte, unsigned long addr) { struct ptdesc *ptdesc = page_ptdesc(pte); - pagetable_dtor(ptdesc); - #ifndef CONFIG_ARM_LPAE /* * With the classic ARM MMU, a pte page has two corresponding pmd @@ -61,7 +61,6 @@ __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmdp, unsigned long addr) #ifdef CONFIG_ARM_LPAE struct ptdesc *ptdesc = virt_to_ptdesc(pmdp); - pagetable_dtor(ptdesc); tlb_remove_ptdesc(tlb, ptdesc); #endif }
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. Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com> Suggested-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: linux-arm-kernel@lists.infradead.org --- arch/arm/include/asm/tlb.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)