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  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 2 Feb 2022 08:45:00 +0000
From:   Christophe Leroy <christophe.leroy@...roup.eu>
To:     Andrey Ryabinin <ryabinin.a.a@...il.com>,
        Alexander Potapenko <glider@...gle.com>,
        Andrey Konovalov <andreyknvl@...il.com>,
        Dmitry Vyukov <dvyukov@...gle.com>,
        Andrew Morton <akpm@...ux-foundation.org>
CC:     Christophe Leroy <christophe.leroy@...roup.eu>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "linux-mm@...ck.org" <linux-mm@...ck.org>,
        "linux-hardening@...r.kernel.org" <linux-hardening@...r.kernel.org>,
        "kasan-dev@...glegroups.com" <kasan-dev@...glegroups.com>
Subject: [PATCH 3/4] powerpc/ptdump: Use kasan_pXX_table()

Instead of opencoding, use the new kasan_pXX_table() helpers.

Signed-off-by: Christophe Leroy <christophe.leroy@...roup.eu>
---
 mm/ptdump.c | 23 ++++++-----------------
 1 file changed, 6 insertions(+), 17 deletions(-)

diff --git a/mm/ptdump.c b/mm/ptdump.c
index da751448d0e4..bb6782de8203 100644
--- a/mm/ptdump.c
+++ b/mm/ptdump.c
@@ -4,7 +4,6 @@
 #include <linux/ptdump.h>
 #include <linux/kasan.h>
 
-#if defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS)
 /*
  * This is an optimization for KASAN=y case. Since all kasan page tables
  * eventually point to the kasan_early_shadow_page we could call note_page()
@@ -15,15 +14,16 @@
 static inline int note_kasan_page_table(struct mm_walk *walk,
 					unsigned long addr)
 {
+#ifdef CONFIG_KASAN_SOFTWARE
 	struct ptdump_state *st = walk->private;
 
 	st->note_page(st, addr, 4, pte_val(kasan_early_shadow_pte[0]));
 
 	walk->action = ACTION_CONTINUE;
+#endif
 
 	return 0;
 }
-#endif
 
 static int ptdump_pgd_entry(pgd_t *pgd, unsigned long addr,
 			    unsigned long next, struct mm_walk *walk)
@@ -31,11 +31,8 @@ static int ptdump_pgd_entry(pgd_t *pgd, unsigned long addr,
 	struct ptdump_state *st = walk->private;
 	pgd_t val = READ_ONCE(*pgd);
 
-#if CONFIG_PGTABLE_LEVELS > 4 && \
-		(defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS))
-	if (pgd_page(val) == virt_to_page(lm_alias(kasan_early_shadow_p4d)))
+	if (kasan_p4d_table(val))
 		return note_kasan_page_table(walk, addr);
-#endif
 
 	if (st->effective_prot)
 		st->effective_prot(st, 0, pgd_val(val));
@@ -52,11 +49,8 @@ static int ptdump_p4d_entry(p4d_t *p4d, unsigned long addr,
 	struct ptdump_state *st = walk->private;
 	p4d_t val = READ_ONCE(*p4d);
 
-#if CONFIG_PGTABLE_LEVELS > 3 && \
-		(defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS))
-	if (p4d_page(val) == virt_to_page(lm_alias(kasan_early_shadow_pud)))
+	if (kasan_pud_table(val))
 		return note_kasan_page_table(walk, addr);
-#endif
 
 	if (st->effective_prot)
 		st->effective_prot(st, 1, p4d_val(val));
@@ -73,11 +67,8 @@ static int ptdump_pud_entry(pud_t *pud, unsigned long addr,
 	struct ptdump_state *st = walk->private;
 	pud_t val = READ_ONCE(*pud);
 
-#if CONFIG_PGTABLE_LEVELS > 2 && \
-		(defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS))
-	if (pud_page(val) == virt_to_page(lm_alias(kasan_early_shadow_pmd)))
+	if (kasan_pmd_table(val))
 		return note_kasan_page_table(walk, addr);
-#endif
 
 	if (st->effective_prot)
 		st->effective_prot(st, 2, pud_val(val));
@@ -94,10 +85,8 @@ static int ptdump_pmd_entry(pmd_t *pmd, unsigned long addr,
 	struct ptdump_state *st = walk->private;
 	pmd_t val = READ_ONCE(*pmd);
 
-#if defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS)
-	if (pmd_page(val) == virt_to_page(lm_alias(kasan_early_shadow_pte)))
+	if (kasan_pte_table(val))
 		return note_kasan_page_table(walk, addr);
-#endif
 
 	if (st->effective_prot)
 		st->effective_prot(st, 3, pmd_val(val));
-- 
2.33.1

Powered by blists - more mailing lists