mirror of https://github.com/ipxe/ipxe.git
[prefix] Delay initrd image copy until memory map is ready
initrd_init() calls umalloc() to allocate space for the initrd image, but does so before hide_etherboot() has been called. It is therefore possible for the initrd to end up overwriting iPXE itself. Fix by converting initrd_init() from an init_fn to a startup_fn. Originally-fixed-by: Till Straumann <strauman@slac.stanford.edu> Signed-off-by: Michael Brown <mcb30@ipxe.org>pull/5/head
parent
b5ed30b2d0
commit
3a4253868c
|
@ -135,6 +135,9 @@ static int cmdline_init ( void ) {
|
||||||
DBGC ( colour, "RUNTIME found command line \"%s\" at %08x\n",
|
DBGC ( colour, "RUNTIME found command line \"%s\" at %08x\n",
|
||||||
cmdline, cmdline_phys );
|
cmdline, cmdline_phys );
|
||||||
|
|
||||||
|
/* Mark command line as consumed */
|
||||||
|
cmdline_phys = 0;
|
||||||
|
|
||||||
/* Strip unwanted cruft from the command line */
|
/* Strip unwanted cruft from the command line */
|
||||||
cmdline_strip ( cmdline, "BOOT_IMAGE=" );
|
cmdline_strip ( cmdline, "BOOT_IMAGE=" );
|
||||||
cmdline_strip ( cmdline, "initrd=" );
|
cmdline_strip ( cmdline, "initrd=" );
|
||||||
|
@ -205,6 +208,9 @@ static int initrd_init ( void ) {
|
||||||
memcpy_user ( image->data, 0, phys_to_user ( initrd_phys ), 0,
|
memcpy_user ( image->data, 0, phys_to_user ( initrd_phys ), 0,
|
||||||
initrd_len );
|
initrd_len );
|
||||||
|
|
||||||
|
/* Mark initrd as consumed */
|
||||||
|
initrd_phys = 0;
|
||||||
|
|
||||||
/* Register image */
|
/* Register image */
|
||||||
if ( ( rc = register_image ( image ) ) != 0 ) {
|
if ( ( rc = register_image ( image ) ) != 0 ) {
|
||||||
DBGC ( colour, "RUNTIME could not register initrd: %s\n",
|
DBGC ( colour, "RUNTIME could not register initrd: %s\n",
|
||||||
|
@ -245,6 +251,6 @@ static void runtime_init ( void ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Command line and initrd initialisation function */
|
/** Command line and initrd initialisation function */
|
||||||
struct init_fn runtime_init_fn __init_fn ( INIT_NORMAL ) = {
|
struct startup_fn runtime_startup_fn __startup_fn ( STARTUP_NORMAL ) = {
|
||||||
.initialise = runtime_init,
|
.startup = runtime_init,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue