[PATCH] arm/kasan: remove the unused code for kasan_pgd_populate

Hailong liu hailongliiu at yeah.net
Sat Jan 9 00:46:32 EST 2021


From: Hailong liu <liu.hailong6 at zte.com.cn>

First, for arm architecture the pgdp is always the same as pmdp. So if we
alloc a table and fill in the entry then it will be overlay later by the
kasan_pmd_populate(), then there will be a leak for the table alloced
kasan_pgd_populate().

On the other hand, pgd_none() always return 0 for arm and therefore this
branch will never be walked.

Signed-off-by: Hailong liu <liu.hailong6 at zte.com.cn>
---
 arch/arm/mm/kasan_init.c | 15 ---------------
 1 file changed, 15 deletions(-)

diff --git a/arch/arm/mm/kasan_init.c b/arch/arm/mm/kasan_init.c
index 9c348042a724..f0e591f7e430 100644
--- a/arch/arm/mm/kasan_init.c
+++ b/arch/arm/mm/kasan_init.c
@@ -126,21 +126,6 @@ static void __init kasan_pgd_populate(unsigned long addr, unsigned long end,
 	pgdp = pgd_offset_k(addr);
 
 	do {
-		/*
-		 * Allocate and populate the shadow block of p4d folded into
-		 * pud folded into pmd if it doesn't already exist
-		 */
-		if (!early && pgd_none(*pgdp)) {
-			void *p = kasan_alloc_block(PAGE_SIZE);
-
-			if (!p) {
-				panic("%s failed to allocate shadow block for address 0x%lx\n",
-				      __func__, addr);
-				return;
-			}
-			pgd_populate(&init_mm, pgdp, p);
-		}
-
 		next = pgd_addr_end(addr, end);
 		/*
 		 * We just immediately jump over the p4d and pud page
-- 
2.17.1




More information about the linux-arm-kernel mailing list