lkml.org 
[lkml]   [2008]   [Sep]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] kexec, kernel 2.6.26.5, segmentation fault in kimage_add_entry
A segmentation fault can occur in kimage_add_entry in kexec.c when 
loading a kernel image into memory. The fault occurs because a page is
requested by calling kimage_alloc_page with gfp_mask GFP_KERNEL and the
function may actually return a page with gfp_mask GFP_HIGHUSER. The high
mem page is returned because it was swapped with the kernel page due to
the kernel page being a page that will shortly be copied to.

This patch ensures that kimage_alloc_page returns a page that was
created with the correct gfp flags.

--- linux-2.6.26.5.orig/kernel/kexec.c 2008-09-16 13:17:56.000000000
-0400
+++ linux-2.6.26.5/kernel/kexec.c 2008-09-16 13:26:35.000000000 -0400
@@ -743,8 +743,15 @@ static struct page *kimage_alloc_page(st
*old = addr | (*old & ~PAGE_MASK);

/* The old page I have found cannot be a
- * destination page, so return it.
- */
+ * destination page, so return it if its
+ * gfp_flags honor the ones passed in.
+ */
+ if (!(gfp_mask & __GFP_HIGHMEM) &&
+ PageHighMem(old_page)) {
+ kimage_free_pages(old_page);
+ continue;
+ }
+
addr = old_addr;
page = old_page;
break;
Signed-off-by: Jonathan Steel <jon.steel@esentire.com>

Jonathan Steel


\
 
 \ /
  Last update: 2008-09-16 21:33    [W:0.150 / U:0.164 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site