aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHeiko Carstens <heiko.carstens@de.ibm.com>2008-07-14 03:58:55 -0400
committerHeiko Carstens <heiko.carstens@de.ibm.com>2008-07-14 04:02:09 -0400
commit761cdf6aacdb76f819050f4938cdab1f4cdcb945 (patch)
treeb24f8709da4445f16086c9caec390bf82895f1c4
parent63506c41986c4af9d4fd6f3490e98e335f3dc8f5 (diff)
[S390] initrd vs bss section clearing.
In case the initrd is located within the bss section it will be overwritten when the section is cleared. To prevent this just move the initrd right behind the bss section if it starts within the section. The current code already moves the initrd if the bootmem allocator bitmap would overwrite it. With this patch we should be safe against initrd corruptions. Cc: Peter Oberparleiter <peter.oberparleiter@de.ibm.com> Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
-rw-r--r--arch/s390/kernel/early.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/arch/s390/kernel/early.c b/arch/s390/kernel/early.c
index d0e09684b9ce..b2226e41f067 100644
--- a/arch/s390/kernel/early.c
+++ b/arch/s390/kernel/early.c
@@ -380,6 +380,23 @@ static __init void detect_machine_facilities(void)
380#endif 380#endif
381} 381}
382 382
383static __init void rescue_initrd(void)
384{
385#ifdef CONFIG_BLK_DEV_INITRD
386 /*
387 * Move the initrd right behind the bss section in case it starts
388 * within the bss section. So we don't overwrite it when the bss
389 * section gets cleared.
390 */
391 if (!INITRD_START || !INITRD_SIZE)
392 return;
393 if (INITRD_START >= (unsigned long) __bss_stop)
394 return;
395 memmove(__bss_stop, (void *) INITRD_START, INITRD_SIZE);
396 INITRD_START = (unsigned long) __bss_stop;
397#endif
398}
399
383/* 400/*
384 * Save ipl parameters, clear bss memory, initialize storage keys 401 * Save ipl parameters, clear bss memory, initialize storage keys
385 * and create a kernel NSS at startup if the SAVESYS= parm is defined 402 * and create a kernel NSS at startup if the SAVESYS= parm is defined
@@ -389,6 +406,7 @@ void __init startup_init(void)
389 unsigned long long memsize; 406 unsigned long long memsize;
390 407
391 ipl_save_parameters(); 408 ipl_save_parameters();
409 rescue_initrd();
392 clear_bss_section(); 410 clear_bss_section();
393 init_kernel_storage_key(); 411 init_kernel_storage_key();
394 lockdep_init(); 412 lockdep_init();