[PATCH][2.6-mm] defer free_initmem() if we have no /init

From: Zwane Mwaikambo
Date: Mon Mar 22 2004 - 01:43:38 EST


In the absence of /init and other nice boot goodies, we fall through to
prepare_namespace() so we shall require initmem to complete boot.

Freeing 1nunedlketo lamdlo y:r3elkpfgeeg
equest at virtual address c06c22a0
printing eip:
c06c22a0
*pde = 00757027
Oops: 0000 [#1]
PREEMPT SMP DEBUG_PAGEALLOC
CPU: 1
EIP: 0060:[<c06c22a0>] Not tainted VLI
EFLAGS: 00010213 (2.6.5-rc2-mm1)
EIP is at prepare_namespace+0x0/0xd0
eax: 00000002 ebx: 00000000 ecx: c060b2c0 edx: c060b300
esi: 00000001 edi: 00000000 ebp: dff8ffec esp: dff8ffd4
ds: 007b es: 007b ss: 0068
Process swapper (pid: 1, threadinfo=dff8f000 task=dff1fa50)
Stack: c0103235 00000000 00000000 0000007b c0103170 00000000 00000000 c01051f5
00000000 00000000 00000000
Call Trace:
[<c0103235>] init+0xc5/0x190
[<c0103170>] init+0x0/0x190
[<c01051f5>] kernel_thread_helper+0x5/0x10

Code: Bad EIP value.
<0>Kernel panic: Attempted to kill init!

Index: linux-2.6.5-rc2-mm1/init/main.c
===================================================================
RCS file: /home/cvsroot/linux-2.6.5-rc2-mm1/init/main.c,v
retrieving revision 1.1.1.1
diff -u -p -B -r1.1.1.1 main.c
--- linux-2.6.5-rc2-mm1/init/main.c 21 Mar 2004 17:02:18 -0000 1.1.1.1
+++ linux-2.6.5-rc2-mm1/init/main.c 21 Mar 2004 20:54:19 -0000
@@ -586,8 +586,8 @@ static int free_initmem_on_exec_helper(v
char c;

sys_close(fd[1]);
- sys_read(fd[0], &c, 1);
- free_initmem();
+ if (sys_read(fd[0], &c, 1) > 0)
+ free_initmem();
return 0;
}

@@ -596,7 +596,7 @@ static void free_initmem_on_exec(void)
int fd[2];

do_pipe(fd);
- kernel_thread(free_initmem_on_exec_helper, &fd, SIGCHLD);
+ kernel_thread(free_initmem_on_exec_helper, &fd, SIGCHLD);

sys_dup2(fd[1], 255); /* to get it out of the way */
sys_close(fd[0]);
@@ -643,6 +643,7 @@ static int init(void * unused)
run_init_process("/init");

prepare_namespace();
+ free_initmem();

if (sys_open("/dev/console", O_RDWR, 0) < 0)
printk("Warning: unable to open an initial console.\n");
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/