Patch "mm/vmalloc: fix page mapping if vm_area_alloc_pages() with high order fallback to order 0" has been added to the 6.6-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

    mm/vmalloc: fix page mapping if vm_area_alloc_pages() with high order fallback to order 0

to the 6.6-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:
     mm-vmalloc-fix-page-mapping-if-vm_area_alloc_pages-w.patch
and it can be found in the queue-6.6 subdirectory.

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



commit 09369399e55a001e315d20eb951f822b702dc628
Author: Hailong Liu <hailong.liu@xxxxxxxx>
Date:   Thu Aug 8 20:19:56 2024 +0800

    mm/vmalloc: fix page mapping if vm_area_alloc_pages() with high order fallback to order 0
    
    [ Upstream commit 61ebe5a747da649057c37be1c37eb934b4af79ca ]
    
    The __vmap_pages_range_noflush() assumes its argument pages** contains
    pages with the same page shift.  However, since commit e9c3cda4d86e ("mm,
    vmalloc: fix high order __GFP_NOFAIL allocations"), if gfp_flags includes
    __GFP_NOFAIL with high order in vm_area_alloc_pages() and page allocation
    failed for high order, the pages** may contain two different page shifts
    (high order and order-0).  This could lead __vmap_pages_range_noflush() to
    perform incorrect mappings, potentially resulting in memory corruption.
    
    Users might encounter this as follows (vmap_allow_huge = true, 2M is for
    PMD_SIZE):
    
    kvmalloc(2M, __GFP_NOFAIL|GFP_X)
        __vmalloc_node_range_noprof(vm_flags=VM_ALLOW_HUGE_VMAP)
            vm_area_alloc_pages(order=9) ---> order-9 allocation failed and fallback to order-0
                vmap_pages_range()
                    vmap_pages_range_noflush()
                        __vmap_pages_range_noflush(page_shift = 21) ----> wrong mapping happens
    
    We can remove the fallback code because if a high-order allocation fails,
    __vmalloc_node_range_noprof() will retry with order-0.  Therefore, it is
    unnecessary to fallback to order-0 here.  Therefore, fix this by removing
    the fallback code.
    
    Link: https://lkml.kernel.org/r/20240808122019.3361-1-hailong.liu@xxxxxxxx
    Fixes: e9c3cda4d86e ("mm, vmalloc: fix high order __GFP_NOFAIL allocations")
    Signed-off-by: Hailong Liu <hailong.liu@xxxxxxxx>
    Reported-by: Tangquan Zheng <zhengtangquan@xxxxxxxx>
    Reviewed-by: Baoquan He <bhe@xxxxxxxxxx>
    Reviewed-by: Uladzislau Rezki (Sony) <urezki@xxxxxxxxx>
    Acked-by: Barry Song <baohua@xxxxxxxxxx>
    Acked-by: Michal Hocko <mhocko@xxxxxxxx>
    Cc: Matthew Wilcox <willy@xxxxxxxxxxxxx>
    Cc: <stable@xxxxxxxxxxxxxxx>
    Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 078f6b53f8d50..732ff66d1b513 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -3079,15 +3079,8 @@ vm_area_alloc_pages(gfp_t gfp, int nid,
 			page = alloc_pages(alloc_gfp, order);
 		else
 			page = alloc_pages_node(nid, alloc_gfp, order);
-		if (unlikely(!page)) {
-			if (!nofail)
-				break;
-
-			/* fall back to the zero order allocations */
-			alloc_gfp |= __GFP_NOFAIL;
-			order = 0;
-			continue;
-		}
+		if (unlikely(!page))
+			break;
 
 		/*
 		 * Higher order allocations must be able to be treated as




[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