stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3.18-rc3] param: fix crash on bad kernel arguments
@ 2014-11-05 15:04 Daniel Thompson
  2014-11-11  6:00 ` Rusty Russell
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Thompson @ 2014-11-05 15:04 UTC (permalink / raw)
  To: Rusty Russell
  Cc: Daniel Thompson, Andrew Morton, linux-kernel, patches,
	linaro-kernel, John Stultz, Sumit Semwal, stable

Currently if the user passes an invalid value on the kernel command line
then the kernel will crash during argument parsing. On most systems this
is very hard to debug because the console hasn't been initialized yet.

This is a regression due to commit 51e158c12aca ("param: hand arguments
after -- straight to init") which, in response to the systemd debug
controversy, made it possible to explicitly pass arguments to init. To
achieve this parse_args() was extended from simply returning an error
code to returning a pointer. Regretably the new init args logic does not
perform a proper validity check on the pointer resulting in a crash.

This patch fixes the validity check. Should the check fail then no arguments
will be passed to init. This is reasonable and matches how the kernel treats
its own arguments (i.e. no error recovery).

Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
Cc: stable@vger.kernel.org
---
 init/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/init/main.c b/init/main.c
index 800a0da..321d0ce 100644
--- a/init/main.c
+++ b/init/main.c
@@ -544,7 +544,7 @@ asmlinkage __visible void __init start_kernel(void)
 				  static_command_line, __start___param,
 				  __stop___param - __start___param,
 				  -1, -1, &unknown_bootoption);
-	if (after_dashes)
+	if (!IS_ERR_OR_NULL(after_dashes))
 		parse_args("Setting init args", after_dashes, NULL, 0, -1, -1,
 			   set_init_arg);

--
1.9.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v3.18-rc3] param: fix crash on bad kernel arguments
  2014-11-05 15:04 [PATCH v3.18-rc3] param: fix crash on bad kernel arguments Daniel Thompson
@ 2014-11-11  6:00 ` Rusty Russell
  0 siblings, 0 replies; 2+ messages in thread
From: Rusty Russell @ 2014-11-11  6:00 UTC (permalink / raw)
  To: Daniel Thompson
  Cc: Daniel Thompson, Andrew Morton, linux-kernel, patches,
	linaro-kernel, John Stultz, Sumit Semwal, stable

Daniel Thompson <daniel.thompson@linaro.org> writes:
> Currently if the user passes an invalid value on the kernel command line
> then the kernel will crash during argument parsing. On most systems this
> is very hard to debug because the console hasn't been initialized yet.

Good catch, applied!

Thanks,
Rusty.

>
> This is a regression due to commit 51e158c12aca ("param: hand arguments
> after -- straight to init") which, in response to the systemd debug
> controversy, made it possible to explicitly pass arguments to init. To
> achieve this parse_args() was extended from simply returning an error
> code to returning a pointer. Regretably the new init args logic does not
> perform a proper validity check on the pointer resulting in a crash.
>
> This patch fixes the validity check. Should the check fail then no arguments
> will be passed to init. This is reasonable and matches how the kernel treats
> its own arguments (i.e. no error recovery).
>
> Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
> Cc: stable@vger.kernel.org
> ---
>  init/main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/init/main.c b/init/main.c
> index 800a0da..321d0ce 100644
> --- a/init/main.c
> +++ b/init/main.c
> @@ -544,7 +544,7 @@ asmlinkage __visible void __init start_kernel(void)
>  				  static_command_line, __start___param,
>  				  __stop___param - __start___param,
>  				  -1, -1, &unknown_bootoption);
> -	if (after_dashes)
> +	if (!IS_ERR_OR_NULL(after_dashes))
>  		parse_args("Setting init args", after_dashes, NULL, 0, -1, -1,
>  			   set_init_arg);
>
> --
> 1.9.3

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-11-11  6:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-05 15:04 [PATCH v3.18-rc3] param: fix crash on bad kernel arguments Daniel Thompson
2014-11-11  6:00 ` Rusty Russell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).