Patch "mm/huge_memory: use pfn_to_online_page() in split_huge_pages_all()" 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

    mm/huge_memory: use pfn_to_online_page() in split_huge_pages_all()

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:
     mm-huge_memory-use-pfn_to_online_page-in-split_huge_.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 b5ca1a496fe1123692a6e340da8510b664e40bc5
Author: Naoya Horiguchi <naoya.horiguchi@xxxxxxx>
Date:   Thu Sep 8 13:11:50 2022 +0900

    mm/huge_memory: use pfn_to_online_page() in split_huge_pages_all()
    
    [ Upstream commit 2b7aa91ba0e86b8643f5d3c83874c80599c731d7 ]
    
    NULL pointer dereference is triggered when calling thp split via debugfs
    on the system with offlined memory blocks.  With debug option enabled, the
    following kernel messages are printed out:
    
      page:00000000467f4890 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x121c000
      flags: 0x17fffc00000000(node=0|zone=2|lastcpupid=0x1ffff)
      raw: 0017fffc00000000 0000000000000000 dead000000000122 0000000000000000
      raw: 0000000000000000 0000000000000000 00000001ffffffff 0000000000000000
      page dumped because: unmovable page
      page:000000007d7ab72e is uninitialized and poisoned
      page dumped because: VM_BUG_ON_PAGE(PagePoisoned(p))
      ------------[ cut here ]------------
      kernel BUG at include/linux/mm.h:1248!
      invalid opcode: 0000 [#1] PREEMPT SMP PTI
      CPU: 16 PID: 20964 Comm: bash Tainted: G          I        6.0.0-rc3-foll-numa+ #41
      ...
      RIP: 0010:split_huge_pages_write+0xcf4/0xe30
    
    This shows that page_to_nid() in page_zone() is unexpectedly called for an
    offlined memmap.
    
    Use pfn_to_online_page() to get struct page in PFN walker.
    
    Link: https://lkml.kernel.org/r/20220908041150.3430269-1-naoya.horiguchi@xxxxxxxxx
    Fixes: f1dd2cd13c4b ("mm, memory_hotplug: do not associate hotadded memory to zones until online")      [visible after d0dc12e86b319]
    Signed-off-by: Naoya Horiguchi <naoya.horiguchi@xxxxxxx>
    Co-developed-by: David Hildenbrand <david@xxxxxxxxxx>
    Signed-off-by: David Hildenbrand <david@xxxxxxxxxx>
    Reviewed-by: Yang Shi <shy828301@xxxxxxxxx>
    Acked-by: Michal Hocko <mhocko@xxxxxxxx>
    Reviewed-by: Miaohe Lin <linmiaohe@xxxxxxxxxx>
    Reviewed-by: Oscar Salvador <osalvador@xxxxxxx>
    Acked-by: Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx>
    Cc: Matthew Wilcox <willy@xxxxxxxxxxxxx>
    Cc: Muchun Song <songmuchun@xxxxxxxxxxxxx>
    Cc: <stable@xxxxxxxxxxxxxxx>    [5.10+]
    Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 34d2979489fd..07941a1540cb 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -2885,11 +2885,9 @@ static void split_huge_pages_all(void)
 		max_zone_pfn = zone_end_pfn(zone);
 		for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++) {
 			int nr_pages;
-			if (!pfn_valid(pfn))
-				continue;
 
-			page = pfn_to_page(pfn);
-			if (!get_page_unless_zero(page))
+			page = pfn_to_online_page(pfn);
+			if (!page || !get_page_unless_zero(page))
 				continue;
 
 			if (zone != page_zone(page))



[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