All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] arm64: mm: assign PXN permission in trans_pgd
@ 2021-11-11  6:03 Pingfan Liu
  2021-11-11 16:09 ` Catalin Marinas
  2021-11-12  5:22 ` [PATCHv2] arm64: mm: Fix VM_BUG_ON(mm != &init_mm) for trans_pgd Pingfan Liu
  0 siblings, 2 replies; 10+ messages in thread
From: Pingfan Liu @ 2021-11-11  6:03 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Pingfan Liu, Catalin Marinas, Will Deacon, Pasha Tatashin,
	James Morse, Matthias Brugger

trans_pgd_create_copy() can hit "VM_BUG_ON(mm != &init_mm)" in the
function pmd_populate_kernel().

p?d_populate() helpers resort to the input parameter mm_struct to decide
the attribute: UXN or PXN. And plus the fact, either hibernation or
kexec runs in privilege mode. So the bug can be fixed by assigning
&init_mm to the callsites of these helpers.

Signed-off-by: Pingfan Liu <kernelfans@gmail.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: James Morse <james.morse@arm.com>
Cc: Matthias Brugger <mbrugger@suse.com>
To: linux-arm-kernel@lists.infradead.org
---
 arch/arm64/mm/trans_pgd.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm64/mm/trans_pgd.c b/arch/arm64/mm/trans_pgd.c
index d7da8ca40d2e..7b43d179e94d 100644
--- a/arch/arm64/mm/trans_pgd.c
+++ b/arch/arm64/mm/trans_pgd.c
@@ -67,7 +67,7 @@ static int copy_pte(struct trans_pgd_info *info, pmd_t *dst_pmdp,
 	dst_ptep = trans_alloc(info);
 	if (!dst_ptep)
 		return -ENOMEM;
-	pmd_populate_kernel(NULL, dst_pmdp, dst_ptep);
+	pmd_populate_kernel(&init_mm, dst_pmdp, dst_ptep);
 	dst_ptep = pte_offset_kernel(dst_pmdp, start);
 
 	src_ptep = pte_offset_kernel(src_pmdp, start);
@@ -90,7 +90,7 @@ static int copy_pmd(struct trans_pgd_info *info, pud_t *dst_pudp,
 		dst_pmdp = trans_alloc(info);
 		if (!dst_pmdp)
 			return -ENOMEM;
-		pud_populate(NULL, dst_pudp, dst_pmdp);
+		pud_populate(&init_mm, dst_pudp, dst_pmdp);
 	}
 	dst_pmdp = pmd_offset(dst_pudp, start);
 
@@ -126,7 +126,7 @@ static int copy_pud(struct trans_pgd_info *info, p4d_t *dst_p4dp,
 		dst_pudp = trans_alloc(info);
 		if (!dst_pudp)
 			return -ENOMEM;
-		p4d_populate(NULL, dst_p4dp, dst_pudp);
+		p4d_populate(&init_mm, dst_p4dp, dst_pudp);
 	}
 	dst_pudp = pud_offset(dst_p4dp, start);
 
-- 
2.31.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-11-16 10:41 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-11  6:03 [PATCH] arm64: mm: assign PXN permission in trans_pgd Pingfan Liu
2021-11-11 16:09 ` Catalin Marinas
2021-11-11 16:13   ` Ard Biesheuvel
2021-11-11 18:18     ` Catalin Marinas
2021-11-11 18:24       ` Catalin Marinas
2021-11-12  5:18       ` Pingfan Liu
2021-11-12  5:22 ` [PATCHv2] arm64: mm: Fix VM_BUG_ON(mm != &init_mm) for trans_pgd Pingfan Liu
2021-11-12 14:26   ` Catalin Marinas
2021-11-12 14:37   ` Pasha Tatashin
2021-11-16 10:39   ` Will Deacon

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.