WSL2-Linux-Kernel/arch/mn10300/kernel
Akira Takeuchi e3f12a5304 mn10300: Use early_param() to parse "mem=" parameter
This fixes the problem that "init=" options may not be passed to kernel
correctly.

parse_mem_cmdline() of mn10300 arch gets rid of "mem=" string from
redboot_command_line. Then init_setup() parses the "init=" options from
static_command_line, which is a copy of redboot_command_line, and keeps
the pointer to the init options in execute_command variable.

Since the commit 026cee0 upstream (params: <level>_initcall-like kernel
parameters), static_command_line becomes overwritten by saved_command_line at
do_initcall_level(). Notice that saved_command_line is a command line
which includes "mem=" string.

As a result, execute_command may point to weird string by the length of
"mem=" parameter.
I noticed this problem when using the command line like this:

    mem=128M console=ttyS0,115200 init=/bin/sh

Here is the processing flow of command line parameters.
    start_kernel()
      setup_arch(&command_line)
         parse_mem_cmdline(cmdline_p)
           * strcpy(boot_command_line, redboot_command_line);
           * Remove "mem=xxx" from redboot_command_line.
           * *cmdline_p = redboot_command_line;
      setup_command_line(command_line) <-- command_line is redboot_command_line
        * strcpy(saved_command_line, boot_command_line)
        * strcpy(static_command_line, command_line)
      parse_early_param()
        strlcpy(tmp_cmdline, boot_command_line, COMMAND_LINE_SIZE);
        parse_early_options(tmp_cmdline);
          parse_args("early options", cmdline, NULL, 0, 0, 0, do_early_param);
      parse_args("Booting ..", static_command_line, ...);
        init_setup() <-- save the pointer in execute_command
      rest_init()
        kernel_thread(kernel_init, NULL, CLONE_FS | CLONE_SIGHAND);

At this point, execute_command points to "/bin/sh" string.

    kernel_init()
      kernel_init_freeable()
        do_basic_setup()
          do_initcalls()
            do_initcall_level()
              (*) strcpy(static_command_line, saved_command_line);

Here, execute_command gets to point to "200" string !!

Signed-off-by: David Howells <dhowells@redhat.com>
2013-06-28 16:53:03 +01:00
..
Makefile mn10300: switch to generic kernel_execve() 2012-10-01 00:53:59 -04:00
asm-offsets.c MN10300: fix SMP synchronization between txdma and serial driver 2012-12-12 15:46:14 +00:00
cevt-mn10300.c
csrc-mn10300.c
entry.S MN10300: Enable IRQs more in system call exit work path 2013-05-30 13:38:48 +09:00
fpu-low.S
fpu-nofpu-low.S
fpu-nofpu.c
fpu.c
gdb-io-serial-low.S
gdb-io-serial.c
gdb-io-ttysm-low.S
gdb-io-ttysm.c
gdb-low.S
gdb-stub.c
head.S
internal.h
io.c
irq.c MN10300: cleanup IRQ affinity setting 2012-12-12 15:46:14 +00:00
kgdb.c
kprobes.c
mn10300-debug.c
mn10300-serial-low.S MN10300: fix SMP synchronization between txdma and serial driver 2012-12-12 15:46:14 +00:00
mn10300-serial.c TTY: mn10300-serial, fix build breakage 2013-01-16 07:36:47 -08:00
mn10300-serial.h MN10300: ttySM: clean up unnecessary casting 2012-12-12 15:46:14 +00:00
mn10300-watchdog-low.S
mn10300-watchdog.c
mn10300_ksyms.c
module.c
process.c dump_stack: unify debug information printed by show_regs() 2013-04-30 17:04:02 -07:00
profile-low.S
profile.c
ptrace.c
rtc.c
setup.c mn10300: Use early_param() to parse "mem=" parameter 2013-06-28 16:53:03 +01:00
sigframe.h
signal.c mn10300: switch to generic old sigaction() 2013-02-03 18:16:04 -05:00
smp-low.S
smp.c mn10300: Use generic idle loop 2013-04-08 17:39:27 +02:00
switch_to.S
sys_mn10300.c
time.c
traps.c dump_stack: consolidate dump_stack() implementations and unify their behaviors 2013-04-30 17:04:02 -07:00
vmlinux.lds.S