All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] init: fix bug where environment vars can't be passed via boot args
@ 2012-04-06 16:53 Chris Metcalf
  2012-04-07 20:29 ` Woody Suwalski
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Chris Metcalf @ 2012-04-06 16:53 UTC (permalink / raw)
  To: Pawel Moll, Ingo Molnar, Peter Zijlstra, Andrew Morton,
	Rusty Russell, Stanislaw Gruszka, linux-kernel

Commit 026cee0086f had the side-effect of dropping the '=' from
the unknown boot arguments that are passed to init as environment
variables.  This is because parse_args() puts a NUL in the string
where the '=' was when it passes the "param" and "val" pointers
to the parsing subfunctions.  Previously, unknown_bootoption() was
the last parse_args() subfunction to run, and it carefully put back
the '=' character.  Now ignore_unknown_bootoption() is the last
one to run, and it wasn't doing the necessary repair, so the
envp params ended up with the embedded NUL and were no longer
seen as valid environment variables by init.

Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
---
 init/main.c |   25 +++++++++++++------------
 1 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/init/main.c b/init/main.c
index 9d454f0..44b2433 100644
--- a/init/main.c
+++ b/init/main.c
@@ -225,13 +225,9 @@ static int __init loglevel(char *str)
 
 early_param("loglevel", loglevel);
 
-/*
- * Unknown boot options get handed to init, unless they look like
- * unused parameters (modprobe will find them in /proc/cmdline).
- */
-static int __init unknown_bootoption(char *param, char *val)
+/* Change NUL term back to "=", to make "param" the whole string. */
+static int __init repair_env_string(char *param, char *val)
 {
-	/* Change NUL term back to "=", to make "param" the whole string. */
 	if (val) {
 		/* param=val or param="val"? */
 		if (val == param+strlen(param)+1)
@@ -243,6 +239,16 @@ static int __init unknown_bootoption(char *param, char *val)
 		} else
 			BUG();
 	}
+	return 0;
+}
+
+/*
+ * Unknown boot options get handed to init, unless they look like
+ * unused parameters (modprobe will find them in /proc/cmdline).
+ */
+static int __init unknown_bootoption(char *param, char *val)
+{
+	repair_env_string(param, val);
 
 	/* Handle obsolete-style parameters */
 	if (obsolete_checksetup(param))
@@ -732,11 +738,6 @@ static char *initcall_level_names[] __initdata = {
 	"late parameters",
 };
 
-static int __init ignore_unknown_bootoption(char *param, char *val)
-{
-	return 0;
-}
-
 static void __init do_initcall_level(int level)
 {
 	extern const struct kernel_param __start___param[], __stop___param[];
@@ -747,7 +748,7 @@ static void __init do_initcall_level(int level)
 		   static_command_line, __start___param,
 		   __stop___param - __start___param,
 		   level, level,
-		   ignore_unknown_bootoption);
+		   repair_env_string);
 
 	for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++)
 		do_one_initcall(*fn);
-- 
1.6.5.2


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

* Re: [PATCH] init: fix bug where environment vars can't be passed via boot args
  2012-04-06 16:53 [PATCH] init: fix bug where environment vars can't be passed via boot args Chris Metcalf
@ 2012-04-07 20:29 ` Woody Suwalski
  2012-04-10 13:15 ` Pawel Moll
  2012-04-19 22:17 ` Andrew Morton
  2 siblings, 0 replies; 6+ messages in thread
From: Woody Suwalski @ 2012-04-07 20:29 UTC (permalink / raw)
  To: Chris Metcalf
  Cc: Pawel Moll, Ingo Molnar, Peter Zijlstra, Andrew Morton,
	Rusty Russell, Stanislaw Gruszka, linux-kernel

Chris Metcalf wrote:
> Commit 026cee0086f had the side-effect of dropping the '=' from
> the unknown boot arguments that are passed to init as environment
> variables.  This is because parse_args() puts a NUL in the string
> where the '=' was when it passes the "param" and "val" pointers
> to the parsing subfunctions.  Previously, unknown_bootoption() was
> the last parse_args() subfunction to run, and it carefully put back
> the '=' character.  Now ignore_unknown_bootoption() is the last
> one to run, and it wasn't doing the necessary repair, so the
> envp params ended up with the embedded NUL and were no longer
> seen as valid environment variables by init.
>
> Signed-off-by: Chris Metcalf<cmetcalf@tilera.com>
> ---
>   init/main.c |   25 +++++++++++++------------
>   1 files changed, 13 insertions(+), 12 deletions(-)
>
> diff --git a/init/main.c b/init/main.c
> index 9d454f0..44b2433 100644
> --- a/init/main.c
> +++ b/init/main.c
> @@ -225,13 +225,9 @@ static int __init loglevel(char *str)
>
>   early_param("loglevel", loglevel);
>
> -/*
> - * Unknown boot options get handed to init, unless they look like
> - * unused parameters (modprobe will find them in /proc/cmdline).
> - */
> -static int __init unknown_bootoption(char *param, char *val)
> +/* Change NUL term back to "=", to make "param" the whole string. */
> +static int __init repair_env_string(char *param, char *val)
>   {
> -	/* Change NUL term back to "=", to make "param" the whole string. */
>   	if (val) {
>   		/* param=val or param="val"? */
>   		if (val == param+strlen(param)+1)
> @@ -243,6 +239,16 @@ static int __init unknown_bootoption(char *param, char *val)
>   		} else
>   			BUG();
>   	}
> +	return 0;
> +}
> +
> +/*
> + * Unknown boot options get handed to init, unless they look like
> + * unused parameters (modprobe will find them in /proc/cmdline).
> + */
> +static int __init unknown_bootoption(char *param, char *val)
> +{
> +	repair_env_string(param, val);
>
>   	/* Handle obsolete-style parameters */
>   	if (obsolete_checksetup(param))
> @@ -732,11 +738,6 @@ static char *initcall_level_names[] __initdata = {
>   	"late parameters",
>   };
>
> -static int __init ignore_unknown_bootoption(char *param, char *val)
> -{
> -	return 0;
> -}
> -
>   static void __init do_initcall_level(int level)
>   {
>   	extern const struct kernel_param __start___param[], __stop___param[];
> @@ -747,7 +748,7 @@ static void __init do_initcall_level(int level)
>   		   static_command_line, __start___param,
>   		   __stop___param - __start___param,
>   		   level, level,
> -		   ignore_unknown_bootoption);
> +		   repair_env_string);
>
>   	for (fn = initcall_levels[level]; fn<  initcall_levels[level+1]; fn++)
>   		do_one_initcall(*fn);

Thanks for the patch, works for me...
Woody


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

* Re: [PATCH] init: fix bug where environment vars can't be passed via boot args
  2012-04-06 16:53 [PATCH] init: fix bug where environment vars can't be passed via boot args Chris Metcalf
  2012-04-07 20:29 ` Woody Suwalski
@ 2012-04-10 13:15 ` Pawel Moll
  2012-04-19 22:17 ` Andrew Morton
  2 siblings, 0 replies; 6+ messages in thread
From: Pawel Moll @ 2012-04-10 13:15 UTC (permalink / raw)
  To: Chris Metcalf
  Cc: Ingo Molnar, Peter Zijlstra, Andrew Morton, Rusty Russell,
	Stanislaw Gruszka, linux-kernel

On Fri, 2012-04-06 at 17:53 +0100, Chris Metcalf wrote:
> Commit 026cee0086f had the side-effect of dropping the '=' from
> the unknown boot arguments that are passed to init as environment
> variables.  This is because parse_args() puts a NUL in the string
> where the '=' was when it passes the "param" and "val" pointers
> to the parsing subfunctions.  Previously, unknown_bootoption() was
> the last parse_args() subfunction to run, and it carefully put back
> the '=' character.  Now ignore_unknown_bootoption() is the last
> one to run, and it wasn't doing the necessary repair, so the
> envp params ended up with the embedded NUL and were no longer
> seen as valid environment variables by init.
> 
> Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>

Looks sensible to me.

Acked-by: Pawel Moll <pawel.moll@arm.com>

Thanks and apologies about delayed answer (and for causing the problem
in the first place :-)

Paweł



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

* Re: [PATCH] init: fix bug where environment vars can't be passed via boot args
  2012-04-06 16:53 [PATCH] init: fix bug where environment vars can't be passed via boot args Chris Metcalf
  2012-04-07 20:29 ` Woody Suwalski
  2012-04-10 13:15 ` Pawel Moll
@ 2012-04-19 22:17 ` Andrew Morton
  2012-04-20 13:41   ` Chris Metcalf
  2012-04-26 19:54   ` Chris Metcalf
  2 siblings, 2 replies; 6+ messages in thread
From: Andrew Morton @ 2012-04-19 22:17 UTC (permalink / raw)
  To: Chris Metcalf
  Cc: Pawel Moll, Ingo Molnar, Peter Zijlstra, Rusty Russell,
	Stanislaw Gruszka, linux-kernel

On Fri, 6 Apr 2012 12:53:50 -0400
Chris Metcalf <cmetcalf@tilera.com> wrote:

> Commit 026cee0086f had the side-effect of dropping the '=' from
> the unknown boot arguments that are passed to init as environment
> variables.  This is because parse_args() puts a NUL in the string
> where the '=' was when it passes the "param" and "val" pointers
> to the parsing subfunctions.  Previously, unknown_bootoption() was
> the last parse_args() subfunction to run, and it carefully put back
> the '=' character.  Now ignore_unknown_bootoption() is the last
> one to run, and it wasn't doing the necessary repair, so the
> envp params ended up with the embedded NUL and were no longer
> seen as valid environment variables by init.

This patch has been stuck in your tree for a week or two.  The copy
there is missing Woody's Tested-by and (I suspect) his Reported-by and
Pawel's Acked-by.

And because that patch is already in linux-next, I can't (or rather
don't want to) merge it myself.

It needs to be merged into 3.4.  Please fix up the changelog data and
send it in?


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

* Re: [PATCH] init: fix bug where environment vars can't be passed via boot args
  2012-04-19 22:17 ` Andrew Morton
@ 2012-04-20 13:41   ` Chris Metcalf
  2012-04-26 19:54   ` Chris Metcalf
  1 sibling, 0 replies; 6+ messages in thread
From: Chris Metcalf @ 2012-04-20 13:41 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Pawel Moll, Ingo Molnar, Peter Zijlstra, Rusty Russell,
	Stanislaw Gruszka, linux-kernel

On 4/20/2012 12:17 AM, Andrew Morton wrote:
> On Fri, 6 Apr 2012 12:53:50 -0400
> Chris Metcalf <cmetcalf@tilera.com> wrote:
>
>> Commit 026cee0086f had the side-effect of dropping the '=' from
>> the unknown boot arguments that are passed to init as environment
>> variables.  This is because parse_args() puts a NUL in the string
>> where the '=' was when it passes the "param" and "val" pointers
>> to the parsing subfunctions.  Previously, unknown_bootoption() was
>> the last parse_args() subfunction to run, and it carefully put back
>> the '=' character.  Now ignore_unknown_bootoption() is the last
>> one to run, and it wasn't doing the necessary repair, so the
>> envp params ended up with the embedded NUL and were no longer
>> seen as valid environment variables by init.
> This patch has been stuck in your tree for a week or two.  The copy
> there is missing Woody's Tested-by and (I suspect) his Reported-by and
> Pawel's Acked-by.

I pushed it by accident - sorry.  I'll double-check my pending changes more
carefully in the future.  I meant for that tree only to hold tile-specific
stuff, but I had the boot-argument change in my tree so I could do more
effective testing.  I'm on vacation till Tuesday in Croatia, unfortunately,
so I don't really want to try to do more than email.

> And because that patch is already in linux-next, I can't (or rather
> don't want to) merge it myself.
>
> It needs to be merged into 3.4.  Please fix up the changelog data and
> send it in?

I will either fix it up and move it to my stable tree for 3.4 on Wednesday
when I'm back in the office, and ask Linus to pull it, or if you want to
push it, presumably it shouldn't conflict much for linux-next.

-- 
Chris Metcalf, Tilera Corp.
http://www.tilera.com


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

* Re: [PATCH] init: fix bug where environment vars can't be passed via boot args
  2012-04-19 22:17 ` Andrew Morton
  2012-04-20 13:41   ` Chris Metcalf
@ 2012-04-26 19:54   ` Chris Metcalf
  1 sibling, 0 replies; 6+ messages in thread
From: Chris Metcalf @ 2012-04-26 19:54 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Pawel Moll, Ingo Molnar, Peter Zijlstra, Rusty Russell,
	Stanislaw Gruszka, linux-kernel

On 4/19/2012 6:17 PM, Andrew Morton wrote:
> On Fri, 6 Apr 2012 12:53:50 -0400
> Chris Metcalf <cmetcalf@tilera.com> wrote:
>
>> Commit 026cee0086f had the side-effect of dropping the '=' from
>> the unknown boot arguments that are passed to init as environment
>> variables.  This is because parse_args() puts a NUL in the string
>> where the '=' was when it passes the "param" and "val" pointers
>> to the parsing subfunctions.  Previously, unknown_bootoption() was
>> the last parse_args() subfunction to run, and it carefully put back
>> the '=' character.  Now ignore_unknown_bootoption() is the last
>> one to run, and it wasn't doing the necessary repair, so the
>> envp params ended up with the embedded NUL and were no longer
>> seen as valid environment variables by init.
> This patch has been stuck in your tree for a week or two.  The copy
> there is missing Woody's Tested-by and (I suspect) his Reported-by and
> Pawel's Acked-by.
>
> And because that patch is already in linux-next, I can't (or rather
> don't want to) merge it myself.
>
> It needs to be merged into 3.4.  Please fix up the changelog data and
> send it in?

I pulled it out of my linux-next tree and into my stable tree (for -rc
changes).  I'll send Linus a pull request now.  Thanks for noticing.

-- 
Chris Metcalf, Tilera Corp.
http://www.tilera.com


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

end of thread, other threads:[~2012-04-26 19:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-06 16:53 [PATCH] init: fix bug where environment vars can't be passed via boot args Chris Metcalf
2012-04-07 20:29 ` Woody Suwalski
2012-04-10 13:15 ` Pawel Moll
2012-04-19 22:17 ` Andrew Morton
2012-04-20 13:41   ` Chris Metcalf
2012-04-26 19:54   ` Chris Metcalf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.