Skip to contentSkip to conversation

free_initrd_mem fix

Linux-ia64 Takanori Kawano 2 participants 2 messages Jul 24, 2001 – Jul 25, 2001

lore
Share & tools
lore
#0 lore raw

Hello,

Let me do some bug report of your code.

I found that free_initrd_mem() may free the area reserved for platform hardware/firmware if initrd_end is not PAGE_SIZE aligned. When this happened, kernel will use the hw/fw area and will corrupt data in it.

For this data corupption, our ia64 SMP box have crashed when kernel calls EFI runtime services.
My case is as follows:

1) EFI memory map:

    Type       Start            End               # Pages          Attributes
       .
       .
       .
   available  0000000000100000-000000007F932FFF  000000000007F833 0000000000000009
   RT_data    000000007F933000-000000007F933FFF  0000000000000001 8000000000000009
       .
       .
       .

2) initrd_end = 0xe00000007f933000
3) PAGE_SIZE is 16KB

I checked the following patch correct this problem.

ia64/mm/init.c renamed from ia64/mm/init.c.orig +2 -1
@@ -111,7 +111,7 @@
 	 *
 	 * To avoid freeing/using the wrong page (kernel sized) we:
 	 *	- align up the beginning of initrd
-	 *	- keep the end untouched
+	 *	- align down the end of initrd
 	 *
 	 *  |             |
 	 *  |=======| a000
@@ -135,6 +135,7 @@
 	 * initrd_start and keep initrd_end as is.
 	 */
 	start = PAGE_ALIGN(start);
+	end = end & PAGE_MASK;
 
 	if (start < end)
 		printk ("Freeing initrd memory: %ldkB freed\n", (end - start) >> 10);

Please take the fix in, and also consider the patch I sent to linux-ia64-ML few weeks ago(Subject: [Linux-ia64] [PATCH] free_initrd_mem() need to be correct).

regards,

---
Takanori Kawano
Hitachi Ltd,
Internet Systems Platform Division
[email protected]

#1 lore raw

Hi,

Quoted 4 lines · Takanori Kawano

Please take the fix in, and also consider the patch I sent to linux-ia64-ML few weeks ago(Subject: [Linux-ia64] [PATCH] free_initrd_mem() need to be correct).

Your fix is correct and will be integrated into the next patch.

Thanks.

Signature · 1 line
-Stephane