Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

kernel/crash: handle multi-page vmcoreinfo in crash kernel copy

kimage_crash_copy_vmcoreinfo() currently assumes vmcoreinfo fits in a
single page. This breaks if VMCOREINFO_BYTES exceeds PAGE_SIZE.

Allocate the required order of control pages and vmap all pages needed to
safely copy vmcoreinfo into the crash kernel image.

Link: https://lkml.kernel.org/r/20251216132801.807260-3-pnina.feder@mobileye.com
Signed-off-by: Pnina Feder <pnina.feder@mobileye.com>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Baoquan He <bhe@redhat.com>
Cc: Dave Young <dyoung@redhat.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Pnina Feder and committed by
Andrew Morton
b5bfcc1f 76103d1b

+13 -4
+13 -4
kernel/crash_core.c
··· 44 44 45 45 int kimage_crash_copy_vmcoreinfo(struct kimage *image) 46 46 { 47 - struct page *vmcoreinfo_page; 47 + struct page *vmcoreinfo_base; 48 + struct page *vmcoreinfo_pages[DIV_ROUND_UP(VMCOREINFO_BYTES, PAGE_SIZE)]; 49 + unsigned int order, nr_pages; 50 + int i; 48 51 void *safecopy; 52 + 53 + nr_pages = DIV_ROUND_UP(VMCOREINFO_BYTES, PAGE_SIZE); 54 + order = get_order(VMCOREINFO_BYTES); 49 55 50 56 if (!IS_ENABLED(CONFIG_CRASH_DUMP)) 51 57 return 0; ··· 67 61 * happens to generate vmcoreinfo note, hereby we rely on 68 62 * vmap for this purpose. 69 63 */ 70 - vmcoreinfo_page = kimage_alloc_control_pages(image, 0); 71 - if (!vmcoreinfo_page) { 64 + vmcoreinfo_base = kimage_alloc_control_pages(image, order); 65 + if (!vmcoreinfo_base) { 72 66 pr_warn("Could not allocate vmcoreinfo buffer\n"); 73 67 return -ENOMEM; 74 68 } 75 - safecopy = vmap(&vmcoreinfo_page, 1, VM_MAP, PAGE_KERNEL); 69 + for (i = 0; i < nr_pages; i++) 70 + vmcoreinfo_pages[i] = vmcoreinfo_base + i; 71 + 72 + safecopy = vmap(vmcoreinfo_pages, nr_pages, VM_MAP, PAGE_KERNEL); 76 73 if (!safecopy) { 77 74 pr_warn("Could not vmap vmcoreinfo buffer\n"); 78 75 return -ENOMEM;