Patch "migrate: hugetlb: check for hugetlb shared PMD in node migration" has been added to the 5.10-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

    migrate: hugetlb: check for hugetlb shared PMD in node migration

to the 5.10-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:
     migrate-hugetlb-check-for-hugetlb-shared-pmd-in-node.patch
and it can be found in the queue-5.10 subdirectory.

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



commit 8a70178a39a5adc6ceda062addc7b535fa04d2e3
Author: Mike Kravetz <mike.kravetz@xxxxxxxxxx>
Date:   Thu Jan 26 14:27:21 2023 -0800

    migrate: hugetlb: check for hugetlb shared PMD in node migration
    
    [ Upstream commit 73bdf65ea74857d7fb2ec3067a3cec0e261b1462 ]
    
    migrate_pages/mempolicy semantics state that CAP_SYS_NICE is required to
    move pages shared with another process to a different node.  page_mapcount
    > 1 is being used to determine if a hugetlb page is shared.  However, a
    hugetlb page will have a mapcount of 1 if mapped by multiple processes via
    a shared PMD.  As a result, hugetlb pages shared by multiple processes and
    mapped with a shared PMD can be moved by a process without CAP_SYS_NICE.
    
    To fix, check for a shared PMD if mapcount is 1.  If a shared PMD is found
    consider the page shared.
    
    Link: https://lkml.kernel.org/r/20230126222721.222195-3-mike.kravetz@xxxxxxxxxx
    Fixes: e2d8cf405525 ("migrate: add hugepage migration code to migrate_pages()")
    Signed-off-by: Mike Kravetz <mike.kravetz@xxxxxxxxxx>
    Acked-by: Peter Xu <peterx@xxxxxxxxxx>
    Acked-by: David Hildenbrand <david@xxxxxxxxxx>
    Cc: James Houghton <jthoughton@xxxxxxxxxx>
    Cc: Matthew Wilcox <willy@xxxxxxxxxxxxx>
    Cc: Michal Hocko <mhocko@xxxxxxxx>
    Cc: Muchun Song <songmuchun@xxxxxxxxxxxxx>
    Cc: Naoya Horiguchi <naoya.horiguchi@xxxxxxxxx>
    Cc: Vishal Moola (Oracle) <vishal.moola@xxxxxxxxx>
    Cc: Yang Shi <shy828301@xxxxxxxxx>
    Cc: <stable@xxxxxxxxxxxxxxx>
    Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index 59d72b121346f..6c98585f20dfe 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -622,7 +622,8 @@ static int queue_pages_hugetlb(pte_t *pte, unsigned long hmask,
 
 	/* With MPOL_MF_MOVE, we migrate only unshared hugepage. */
 	if (flags & (MPOL_MF_MOVE_ALL) ||
-	    (flags & MPOL_MF_MOVE && page_mapcount(page) == 1)) {
+	    (flags & MPOL_MF_MOVE && page_mapcount(page) == 1 &&
+	     !hugetlb_pmd_shared(pte))) {
 		if (isolate_hugetlb(page, qp->pagelist) &&
 			(flags & MPOL_MF_STRICT))
 			/*



[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