Patch "arm64: mm: fix VA-range sanity check" has been added to the 5.15-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

    arm64: mm: fix VA-range sanity check

to the 5.15-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:
     arm64-mm-fix-va-range-sanity-check.patch
and it can be found in the queue-5.15 subdirectory.

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



commit 880f692f659db0935d94b1f5a9324e70dc02432b
Author: Mark Rutland <mark.rutland@xxxxxxx>
Date:   Thu Jun 15 11:26:28 2023 +0100

    arm64: mm: fix VA-range sanity check
    
    [ Upstream commit ab9b4008092c86dc12497af155a0901cc1156999 ]
    
    Both create_mapping_noalloc() and update_mapping_prot() sanity-check
    their 'virt' parameter, but the check itself doesn't make much sense.
    The condition used today appears to be a historical accident.
    
    The sanity-check condition:
    
            if ((virt >= PAGE_END) && (virt < VMALLOC_START)) {
                    [ ... warning here ... ]
                    return;
            }
    
    ... can only be true for the KASAN shadow region or the module region,
    and there's no reason to exclude these specifically for creating and
    updateing mappings.
    
    When arm64 support was first upstreamed in commit:
    
      c1cc1552616d0f35 ("arm64: MMU initialisation")
    
    ... the condition was:
    
            if (virt < VMALLOC_START) {
                    [ ... warning here ... ]
                    return;
            }
    
    At the time, VMALLOC_START was the lowest kernel address, and this was
    checking whether 'virt' would be translated via TTBR1.
    
    Subsequently in commit:
    
      14c127c957c1c607 ("arm64: mm: Flip kernel VA space")
    
    ... the condition was changed to:
    
            if ((virt >= VA_START) && (virt < VMALLOC_START)) {
                    [ ... warning here ... ]
                    return;
            }
    
    This appear to have been a thinko. The commit moved the linear map to
    the bottom of the kernel address space, with VMALLOC_START being at the
    halfway point. The old condition would warn for changes to the linear
    map below this, and at the time VA_START was the end of the linear map.
    
    Subsequently we cleaned up the naming of VA_START in commit:
    
      77ad4ce69321abbe ("arm64: memory: rename VA_START to PAGE_END")
    
    ... keeping the erroneous condition as:
    
            if ((virt >= PAGE_END) && (virt < VMALLOC_START)) {
                    [ ... warning here ... ]
                    return;
            }
    
    Correct the condition to check against the start of the TTBR1 address
    space, which is currently PAGE_OFFSET. This simplifies the logic, and
    more clearly matches the "outside kernel range" message in the warning.
    
    Signed-off-by: Mark Rutland <mark.rutland@xxxxxxx>
    Cc: Russell King <linux@xxxxxxxxxxxxxxx>
    Cc: Steve Capper <steve.capper@xxxxxxx>
    Cc: Will Deacon <will@xxxxxxxxxx>
    Reviewed-by: Russell King (Oracle) <rmk+kernel@xxxxxxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20230615102628.1052103-1-mark.rutland@xxxxxxx
    Signed-off-by: Catalin Marinas <catalin.marinas@xxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
index 6680689242df3..fc86e7465df42 100644
--- a/arch/arm64/mm/mmu.c
+++ b/arch/arm64/mm/mmu.c
@@ -435,7 +435,7 @@ static phys_addr_t pgd_pgtable_alloc(int shift)
 static void __init create_mapping_noalloc(phys_addr_t phys, unsigned long virt,
 				  phys_addr_t size, pgprot_t prot)
 {
-	if ((virt >= PAGE_END) && (virt < VMALLOC_START)) {
+	if (virt < PAGE_OFFSET) {
 		pr_warn("BUG: not creating mapping for %pa at 0x%016lx - outside kernel range\n",
 			&phys, virt);
 		return;
@@ -462,7 +462,7 @@ void __init create_pgd_mapping(struct mm_struct *mm, phys_addr_t phys,
 static void update_mapping_prot(phys_addr_t phys, unsigned long virt,
 				phys_addr_t size, pgprot_t prot)
 {
-	if ((virt >= PAGE_END) && (virt < VMALLOC_START)) {
+	if (virt < PAGE_OFFSET) {
 		pr_warn("BUG: not updating mapping for %pa at 0x%016lx - outside kernel range\n",
 			&phys, virt);
 		return;



[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