Skip to content

Commit 2b7aa91

Browse files
nhoriguchiakpm00
authored andcommitted
mm/huge_memory: use pfn_to_online_page() in split_huge_pages_all()
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 [raspberrypi#1] PREEMPT SMP PTI CPU: 16 PID: 20964 Comm: bash Tainted: G I 6.0.0-rc3-foll-numa+ raspberrypi#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/[email protected] Fixes: f1dd2cd ("mm, memory_hotplug: do not associate hotadded memory to zones until online") [visible after d0dc12e] Signed-off-by: Naoya Horiguchi <[email protected]> Co-developed-by: David Hildenbrand <[email protected]> Signed-off-by: David Hildenbrand <[email protected]> Reviewed-by: Yang Shi <[email protected]> Acked-by: Michal Hocko <[email protected]> Reviewed-by: Miaohe Lin <[email protected]> Reviewed-by: Oscar Salvador <[email protected]> Acked-by: Kirill A. Shutemov <[email protected]> Cc: Matthew Wilcox <[email protected]> Cc: Muchun Song <[email protected]> Cc: <[email protected]> [5.10+] Signed-off-by: Andrew Morton <[email protected]>
1 parent 58d426a commit 2b7aa91

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

mm/huge_memory.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2894,11 +2894,9 @@ static void split_huge_pages_all(void)
28942894
max_zone_pfn = zone_end_pfn(zone);
28952895
for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++) {
28962896
int nr_pages;
2897-
if (!pfn_valid(pfn))
2898-
continue;
28992897

2900-
page = pfn_to_page(pfn);
2901-
if (!get_page_unless_zero(page))
2898+
page = pfn_to_online_page(pfn);
2899+
if (!page || !get_page_unless_zero(page))
29022900
continue;
29032901

29042902
if (zone != page_zone(page))

0 commit comments

Comments
 (0)