mm-commits mirror
 help / color / mirror / Atom feed
* + bootconfig-do-not-put-quotes-on-cmdline-items-unless-necessary.patch added to mm-nonmm-unstable branch
@ 2024-03-22  0:26 Andrew Morton
  2024-04-09 23:56 ` Masami Hiramatsu
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2024-03-22  0:26 UTC (permalink / raw
  To: mm-commits, mhiramat, linux, akpm


The patch titled
     Subject: bootconfig: do not put quotes on cmdline items unless necessary
has been added to the -mm mm-nonmm-unstable branch.  Its filename is
     bootconfig-do-not-put-quotes-on-cmdline-items-unless-necessary.patch

This patch will shortly appear at
     https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/bootconfig-do-not-put-quotes-on-cmdline-items-unless-necessary.patch

This patch will later appear in the mm-nonmm-unstable branch at
    git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next via the mm-everything
branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there every 2-3 working days

------------------------------------------------------
From: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Subject: bootconfig: do not put quotes on cmdline items unless necessary
Date: Wed, 20 Mar 2024 11:19:52 +0100

When trying to migrate to using bootconfig to embed the kernel's and
PID1's command line with the kernel image itself, and so allowing changing
that without modifying the bootloader, I noticed that /proc/cmdline
changed from e.g.

  console=ttymxc0,115200n8 cma=128M quiet -- --log-level=notice

to

  console="ttymxc0,115200n8" cma="128M" quiet -- --log-level="notice"

The kernel parameters are parsed just fine, and the quotes are indeed
stripped from the actual argv[] given to PID1.  However, the quoting
doesn't really serve any purpose and looks excessive, and might confuse
some (naive) userspace tool trying to parse /proc/cmdline.  So do not
quote the value unless it contains whitespace.

Link: https://lkml.kernel.org/r/20240320101952.62135-1-linux@rasmusvillemoes.dk
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 init/main.c |   12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

--- a/init/main.c~bootconfig-do-not-put-quotes-on-cmdline-items-unless-necessary
+++ a/init/main.c
@@ -327,7 +327,7 @@ static int __init xbc_snprint_cmdline(ch
 {
 	struct xbc_node *knode, *vnode;
 	char *end = buf + size;
-	const char *val;
+	const char *val, *q;
 	int ret;
 
 	xbc_node_for_each_key_value(root, knode, val) {
@@ -345,8 +345,14 @@ static int __init xbc_snprint_cmdline(ch
 			continue;
 		}
 		xbc_array_for_each_value(vnode, val) {
-			ret = snprintf(buf, rest(buf, end), "%s=\"%s\" ",
-				       xbc_namebuf, val);
+			/*
+			 * For prettier and more readable /proc/cmdline, only
+			 * quote the value when necessary, i.e. when it contains
+			 * whitespace.
+			 */
+			q = strpbrk(val, " \t\r\n") ? "\"" : "";
+			ret = snprintf(buf, rest(buf, end), "%s=%s%s%s ",
+				       xbc_namebuf, q, val, q);
 			if (ret < 0)
 				return ret;
 			buf += ret;
_

Patches currently in -mm which might be from linux@rasmusvillemoes.dk are

bootconfig-do-not-put-quotes-on-cmdline-items-unless-necessary.patch


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

* Re: + bootconfig-do-not-put-quotes-on-cmdline-items-unless-necessary.patch added to mm-nonmm-unstable branch
  2024-03-22  0:26 + bootconfig-do-not-put-quotes-on-cmdline-items-unless-necessary.patch added to mm-nonmm-unstable branch Andrew Morton
@ 2024-04-09 23:56 ` Masami Hiramatsu
  2024-04-10 17:37   ` Andrew Morton
  0 siblings, 1 reply; 4+ messages in thread
From: Masami Hiramatsu @ 2024-04-09 23:56 UTC (permalink / raw
  To: Andrew Morton; +Cc: mm-commits, linux

Hi Andrew,

Can I pick this in my bootconfig/for-next tree?

Thank you,

On Thu, 21 Mar 2024 17:26:57 -0700
Andrew Morton <akpm@linux-foundation.org> wrote:

> 
> The patch titled
>      Subject: bootconfig: do not put quotes on cmdline items unless necessary
> has been added to the -mm mm-nonmm-unstable branch.  Its filename is
>      bootconfig-do-not-put-quotes-on-cmdline-items-unless-necessary.patch
> 
> This patch will shortly appear at
>      https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/bootconfig-do-not-put-quotes-on-cmdline-items-unless-necessary.patch
> 
> This patch will later appear in the mm-nonmm-unstable branch at
>     git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
> 
> Before you just go and hit "reply", please:
>    a) Consider who else should be cc'ed
>    b) Prefer to cc a suitable mailing list as well
>    c) Ideally: find the original patch on the mailing list and do a
>       reply-to-all to that, adding suitable additional cc's
> 
> *** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
> 
> The -mm tree is included into linux-next via the mm-everything
> branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
> and is updated there every 2-3 working days
> 
> ------------------------------------------------------
> From: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> Subject: bootconfig: do not put quotes on cmdline items unless necessary
> Date: Wed, 20 Mar 2024 11:19:52 +0100
> 
> When trying to migrate to using bootconfig to embed the kernel's and
> PID1's command line with the kernel image itself, and so allowing changing
> that without modifying the bootloader, I noticed that /proc/cmdline
> changed from e.g.
> 
>   console=ttymxc0,115200n8 cma=128M quiet -- --log-level=notice
> 
> to
> 
>   console="ttymxc0,115200n8" cma="128M" quiet -- --log-level="notice"
> 
> The kernel parameters are parsed just fine, and the quotes are indeed
> stripped from the actual argv[] given to PID1.  However, the quoting
> doesn't really serve any purpose and looks excessive, and might confuse
> some (naive) userspace tool trying to parse /proc/cmdline.  So do not
> quote the value unless it contains whitespace.
> 
> Link: https://lkml.kernel.org/r/20240320101952.62135-1-linux@rasmusvillemoes.dk
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> Cc: Masami Hiramatsu <mhiramat@kernel.org>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> ---
> 
>  init/main.c |   12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> --- a/init/main.c~bootconfig-do-not-put-quotes-on-cmdline-items-unless-necessary
> +++ a/init/main.c
> @@ -327,7 +327,7 @@ static int __init xbc_snprint_cmdline(ch
>  {
>  	struct xbc_node *knode, *vnode;
>  	char *end = buf + size;
> -	const char *val;
> +	const char *val, *q;
>  	int ret;
>  
>  	xbc_node_for_each_key_value(root, knode, val) {
> @@ -345,8 +345,14 @@ static int __init xbc_snprint_cmdline(ch
>  			continue;
>  		}
>  		xbc_array_for_each_value(vnode, val) {
> -			ret = snprintf(buf, rest(buf, end), "%s=\"%s\" ",
> -				       xbc_namebuf, val);
> +			/*
> +			 * For prettier and more readable /proc/cmdline, only
> +			 * quote the value when necessary, i.e. when it contains
> +			 * whitespace.
> +			 */
> +			q = strpbrk(val, " \t\r\n") ? "\"" : "";
> +			ret = snprintf(buf, rest(buf, end), "%s=%s%s%s ",
> +				       xbc_namebuf, q, val, q);
>  			if (ret < 0)
>  				return ret;
>  			buf += ret;
> _
> 
> Patches currently in -mm which might be from linux@rasmusvillemoes.dk are
> 
> bootconfig-do-not-put-quotes-on-cmdline-items-unless-necessary.patch
> 


-- 
Masami Hiramatsu (Google) <mhiramat@kernel.org>

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

* Re: + bootconfig-do-not-put-quotes-on-cmdline-items-unless-necessary.patch added to mm-nonmm-unstable branch
  2024-04-09 23:56 ` Masami Hiramatsu
@ 2024-04-10 17:37   ` Andrew Morton
  2024-04-12  5:19     ` Masami Hiramatsu
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2024-04-10 17:37 UTC (permalink / raw
  To: Masami Hiramatsu; +Cc: mm-commits, linux

On Wed, 10 Apr 2024 08:56:27 +0900 Masami Hiramatsu (Google) <mhiramat@kernel.org> wrote:

> Hi Andrew,
> 
> Can I pick this in my bootconfig/for-next tree?
> 

Please do.  Once it turns up in linux-next I'll drop the mm.git copy. 
This is my standard procedure.


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

* Re: + bootconfig-do-not-put-quotes-on-cmdline-items-unless-necessary.patch added to mm-nonmm-unstable branch
  2024-04-10 17:37   ` Andrew Morton
@ 2024-04-12  5:19     ` Masami Hiramatsu
  0 siblings, 0 replies; 4+ messages in thread
From: Masami Hiramatsu @ 2024-04-12  5:19 UTC (permalink / raw
  To: Andrew Morton; +Cc: mm-commits, linux

On Wed, 10 Apr 2024 10:37:57 -0700
Andrew Morton <akpm@linux-foundation.org> wrote:

> On Wed, 10 Apr 2024 08:56:27 +0900 Masami Hiramatsu (Google) <mhiramat@kernel.org> wrote:
> 
> > Hi Andrew,
> > 
> > Can I pick this in my bootconfig/for-next tree?
> > 
> 
> Please do.  Once it turns up in linux-next I'll drop the mm.git copy. 
> This is my standard procedure.

Thanks for the confirmation!

> 


-- 
Masami Hiramatsu (Google) <mhiramat@kernel.org>

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

end of thread, other threads:[~2024-04-12  5:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-22  0:26 + bootconfig-do-not-put-quotes-on-cmdline-items-unless-necessary.patch added to mm-nonmm-unstable branch Andrew Morton
2024-04-09 23:56 ` Masami Hiramatsu
2024-04-10 17:37   ` Andrew Morton
2024-04-12  5:19     ` Masami Hiramatsu

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 read-only IMAP folder(s) and NNTP newsgroup(s).