lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <0BC12DAA7222E361+20240906082254.435410-2-wangyuli@uniontech.com>
Date: Fri,  6 Sep 2024 16:22:37 +0800
From: WangYuli <wangyuli@...ontech.com>
To: stable@...r.kernel.org,
	gregkh@...uxfoundation.org,
	sashal@...nel.org,
	alexghiti@...osinc.com,
	palmer@...osinc.com,
	wangyuli@...ontech.com
Cc: paul.walmsley@...ive.com,
	palmer@...belt.com,
	aou@...s.berkeley.edu,
	anup@...infault.org,
	linux-riscv@...ts.infradead.org,
	linux-kernel@...r.kernel.org,
	rdunlap@...radead.org,
	dvlachos@....forth.gr,
	bhe@...hat.com,
	samuel.holland@...ive.com,
	guoren@...nel.org,
	linux@...linux.org.uk,
	linux-arm-kernel@...ts.infradead.org,
	willy@...radead.org,
	akpm@...ux-foundation.org,
	fengwei.yin@...el.com,
	prabhakar.mahadev-lad.rj@...renesas.com,
	conor.dooley@...rochip.com,
	glider@...gle.com,
	elver@...gle.com,
	dvyukov@...gle.com,
	kasan-dev@...glegroups.com,
	ardb@...nel.org,
	linux-efi@...r.kernel.org,
	atishp@...shpatra.org,
	kvm@...r.kernel.org,
	kvm-riscv@...ts.infradead.org,
	qiaozhe@...as.ac.cn,
	ryan.roberts@....com,
	ryabinin.a.a@...il.com,
	andreyknvl@...il.com,
	vincenzo.frascino@....com,
	namcao@...utronix.de
Subject: [PATCH 6.6 2/4] mm: Introduce pudp/p4dp/pgdp_get() functions

From: Alexandre Ghiti <alexghiti@...osinc.com>

[ Upstream commit eba2591d99d1f14a04c8a8a845ab0795b93f5646 ]

Instead of directly dereferencing page tables entries, which can cause
issues (see commit 20a004e7b017 ("arm64: mm: Use READ_ONCE/WRITE_ONCE when
accessing page tables"), let's introduce new functions to get the
pud/p4d/pgd entries (the pte and pmd versions already exist).

Note that arm pgd_t is actually an array so pgdp_get() is defined as a
macro to avoid a build error.

Those new functions will be used in subsequent commits by the riscv
architecture.

Signed-off-by: Alexandre Ghiti <alexghiti@...osinc.com>
Link: https://lore.kernel.org/r/20231213203001.179237-3-alexghiti@rivosinc.com
Signed-off-by: Palmer Dabbelt <palmer@...osinc.com>
Signed-off-by: WangYuli <wangyuli@...ontech.com>
---
 arch/arm/include/asm/pgtable.h |  2 ++
 include/linux/pgtable.h        | 21 +++++++++++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
index 16b02f44c7d3..d657b84b6bf7 100644
--- a/arch/arm/include/asm/pgtable.h
+++ b/arch/arm/include/asm/pgtable.h
@@ -151,6 +151,8 @@ extern pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
 
 extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
 
+#define pgdp_get(pgpd)		READ_ONCE(*pgdp)
+
 #define pud_page(pud)		pmd_page(__pmd(pud_val(pud)))
 #define pud_write(pud)		pmd_write(__pmd(pud_val(pud)))
 
diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h
index af7639c3b0a3..8b7daccd11be 100644
--- a/include/linux/pgtable.h
+++ b/include/linux/pgtable.h
@@ -292,6 +292,27 @@ static inline pmd_t pmdp_get(pmd_t *pmdp)
 }
 #endif
 
+#ifndef pudp_get
+static inline pud_t pudp_get(pud_t *pudp)
+{
+	return READ_ONCE(*pudp);
+}
+#endif
+
+#ifndef p4dp_get
+static inline p4d_t p4dp_get(p4d_t *p4dp)
+{
+	return READ_ONCE(*p4dp);
+}
+#endif
+
+#ifndef pgdp_get
+static inline pgd_t pgdp_get(pgd_t *pgdp)
+{
+	return READ_ONCE(*pgdp);
+}
+#endif
+
 #ifndef __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
 static inline int ptep_test_and_clear_young(struct vm_area_struct *vma,
 					    unsigned long address,
-- 
2.43.4


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ