lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 1 Dec 2008 13:18:07 +0000
From:	Russell King <rmk+lkml@....linux.org.uk>
To:	Rusty Russell <rusty@...tcorp.com.au>
Cc:	linux-kernel@...r.kernel.org, Richard Henderson <rth@...ddle.net>,
	Haavard Skinnemoen <hskinnemoen@...el.com>,
	Bryan Wu <cooloney@...nel.org>,
	Mikael Starvik <starvik@...s.com>,
	David Howells <dhowells@...hat.com>,
	Yoshinori Sato <ysato@...rs.sourceforge.jp>,
	Tony Luck <tony.luck@...el.com>,
	Hirokazu Takata <takata@...ux-m32r.org>,
	Geert Uytterhoeven <geert@...ux-m68k.org>,
	Greg Ungerer <gerg@...inux.org>,
	Ralf Baechle <ralf@...ux-mips.org>,
	Grant Grundler <grundler@...isc-linux.org>,
	Paul Mackerras <paulus@...ba.org>,
	Heiko Carstens <heiko.carstens@...ibm.com>,
	Paul Mundt <lethal@...ux-sh.org>,
	"David S. Miller" <davem@...emloft.net>,
	Jeff Dike <jdike@...toit.com>, Ingo Molnar <mingo@...hat.com>,
	Chris Zankel <chris@...kel.net>
Subject: Re: [RFC 5/8] param: arch_get_boot_command_line()

On Mon, Dec 01, 2008 at 11:26:01PM +1030, Rusty Russell wrote:
> diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
> --- a/arch/arm/kernel/setup.c
> +++ b/arch/arm/kernel/setup.c
> @@ -414,9 +414,11 @@ __early_param("mem=", early_mem);
>  
>  /*
>   * Initial parsing of the command line.
> + * FIXME: Use generic early_param / core_param code here.
>   */
> -static void __init parse_cmdline(char **cmdline_p, char *from)
> +static void __init parse_cmdline(void)
>  {
> +	const char *from = boot_command_line;
>  	char c = ' ', *to = command_line;
>  	int len = 0;
>  
> @@ -448,7 +450,6 @@ static void __init parse_cmdline(char **
>  		*to++ = c;
>  	}
>  	*to = '\0';
> -	*cmdline_p = command_line;
>  }
>  
>  static void __init
> @@ -673,11 +674,24 @@ static int __init customize_machine(void
>  }
>  arch_initcall(customize_machine);
>  
> -void __init setup_arch(char **cmdline_p)
> +void arch_get_boot_command_line(void)
> +{
> +	struct machine_desc *mdesc;
> +	const char *from;
> +
> +	mdesc = setup_machine(machine_arch_type);
> +	if (mdesc->cmdline)
> +		from = mdesc->cmdline();
> +	else
> +		from = default_command_line;
> +
> +	strlcpy(boot_command_line, from, COMMAND_LINE_SIZE);

This is only half the story I'm afraid.  It doesn't take account of the
fact that the command line can be passed from the boot loader via the
ATAG structures, which are only parsed after the machine specific
fixup has happened (which can also modify the ATAGs).

You're also not guaranteed to have an ATAG list before setup_arch() is
called - it might be a param_struct, and we convert that to an ATAG list
before ATAG parsing.

So there's quite a bit which needs to be done to get at the command line.
Basically, what's required is:

- convert param struct to tag list
- if no tag list, use default tag list
- run machine specific fixups which may set memory layout
- if memory layout has been set, kill off any memory atags to prevent it
  being overwritten
- parse all atags which includes setting the command line if such a tag
  is found

Then, and only then can you be sure that you have the right command line.

-- 
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ