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]
Message-ID: <CAE9FiQWuei89mmkpThY-ckMut3oRj=61iWk=R7=z2XO0aTekmg@mail.gmail.com>
Date:	Tue, 12 May 2015 16:41:22 -0700
From:	Yinghai Lu <yinghai@...nel.org>
To:	Matthew Garrett <matthew.garrett@...eos.com>
Cc:	Ingo Molnar <mingo@...nel.org>,
	Matthew Garrett <mjg59@...f.ucam.org>,
	"the arch/x86 maintainers" <x86@...nel.org>,
	"H. Peter Anvin" <hpa@...or.com>, Ingo Molnar <mingo@...hat.com>,
	Thomas Gleixner <tglx@...utronix.de>,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
	Matthew Garrett <mjg59@...eos.com>
Subject: Re: [PATCH V2] x86: Allow built-in command line to work in early
 kernel init

On Tue, May 12, 2015 at 11:42 AM, Matthew Garrett
<matthew.garrett@...eos.com> wrote:
> Ok, maybe something more like this? It even gets rid of some of the
> #ifdefs in setup.c.
>
> diff --git a/arch/x86/boot/cmdline.c b/arch/x86/boot/cmdline.c
> index 625d21b..9ddffd0 100644
> --- a/arch/x86/boot/cmdline.c
> +++ b/arch/x86/boot/cmdline.c
> @@ -12,8 +12,15 @@
>   * Simple command-line parser for early boot.
>   */
>
> +#include <asm/cmdline_append.h>
>  #include "boot.h"
>
> +#ifdef CONFIG_CMDLINE_BOOL
> +static char builtin_cmdline[] = CONFIG_CMDLINE;
> +#else
> +static char *builtin_cmdline;
> +#endif
> +
>  static inline int myisspace(u8 c)
>  {
>      return c <= ' ';    /* Close enough approximation */
> @@ -156,3 +163,38 @@ int __cmdline_find_option_bool(unsigned long
> cmdline_ptr, const char *option)
>
>      return 0;    /* Buffer overrun */
>  }
> +
> +int __cmdline_init(unsigned long cmdline_ptr, struct boot_params *params)
> +{
> +    addr_t cptr;
> +    int i = 0;
> +
> +    if (!builtin_cmdline)
> +        return 0;
> +
> +    if (!cmdline_ptr)
> +        return -1;      /* No command line */
> +
> +    set_fs(cmdline_ptr >> 4);
> +    cptr = cmdline_ptr & 0xf;
> +
> +    if (append_cmdline) {
> +        while (cptr < 0x10000) {
> +            char c = rdfs8(cptr);
> +            if (!c) {
> +                wrfs8(' ', cptr++);
> +                break;
> +            }
> +            cptr++;
> +        }
> +    }
> +
> +    while (builtin_cmdline[i] && cptr < 0xffff)
> +        wrfs8(builtin_cmdline[i++], cptr++);
> +
> +    wrfs8('\0', cptr);
> +
> +    params->setup_flags |= SETUP_CMDLINE_APPENDED;
> +
> +    return 0;
> +}

You can not assume that you can use buffer after cmd_line from bootloader
blindly.

Thanks

Yinghai
--
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