Patch "riscv: mm: add missing memcpy in kasan_init" has been added to the 6.0-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    riscv: mm: add missing memcpy in kasan_init

to the 6.0-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     riscv-mm-add-missing-memcpy-in-kasan_init.patch
and it can be found in the queue-6.0 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 49fc7581eda99ed8d727efca4240d2cf6eb5b196
Author: Qinglin Pan <panqinglin2020@xxxxxxxxxxx>
Date:   Sun Oct 9 16:30:50 2022 +0800

    riscv: mm: add missing memcpy in kasan_init
    
    [ Upstream commit 9f2ac64d6ca60db99132e08628ac2899f956a0ec ]
    
    Hi Atish,
    
    It seems that the panic is due to the missing memcpy during kasan_init.
    Could you please check whether this patch is helpful?
    
    When doing kasan_populate, the new allocated base_pud/base_p4d should
    contain kasan_early_shadow_{pud, p4d}'s content. Add the missing memcpy
    to avoid page fault when read/write kasan shadow region.
    
    Tested on:
     - qemu with sv57 and CONFIG_KASAN on.
     - qemu with sv48 and CONFIG_KASAN on.
    
    Signed-off-by: Qinglin Pan <panqinglin2020@xxxxxxxxxxx>
    Tested-by: Atish Patra <atishp@xxxxxxxxxxxx>
    Fixes: 8fbdccd2b173 ("riscv: mm: Support kasan for sv57")
    Link: https://lore.kernel.org/r/20221009083050.3814850-1-panqinglin2020@xxxxxxxxxxx
    Signed-off-by: Palmer Dabbelt <palmer@xxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/arch/riscv/mm/kasan_init.c b/arch/riscv/mm/kasan_init.c
index a22e418dbd82..e1226709490f 100644
--- a/arch/riscv/mm/kasan_init.c
+++ b/arch/riscv/mm/kasan_init.c
@@ -113,6 +113,8 @@ static void __init kasan_populate_pud(pgd_t *pgd,
 		base_pud = pt_ops.get_pud_virt(pfn_to_phys(_pgd_pfn(*pgd)));
 	} else if (pgd_none(*pgd)) {
 		base_pud = memblock_alloc(PTRS_PER_PUD * sizeof(pud_t), PAGE_SIZE);
+		memcpy(base_pud, (void *)kasan_early_shadow_pud,
+			sizeof(pud_t) * PTRS_PER_PUD);
 	} else {
 		base_pud = (pud_t *)pgd_page_vaddr(*pgd);
 		if (base_pud == lm_alias(kasan_early_shadow_pud)) {
@@ -173,8 +175,11 @@ static void __init kasan_populate_p4d(pgd_t *pgd,
 		base_p4d = pt_ops.get_p4d_virt(pfn_to_phys(_pgd_pfn(*pgd)));
 	} else {
 		base_p4d = (p4d_t *)pgd_page_vaddr(*pgd);
-		if (base_p4d == lm_alias(kasan_early_shadow_p4d))
+		if (base_p4d == lm_alias(kasan_early_shadow_p4d)) {
 			base_p4d = memblock_alloc(PTRS_PER_PUD * sizeof(p4d_t), PAGE_SIZE);
+			memcpy(base_p4d, (void *)kasan_early_shadow_p4d,
+				sizeof(p4d_t) * PTRS_PER_P4D);
+		}
 	}
 
 	p4dp = base_p4d + p4d_index(vaddr);



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux