From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E1E494519AE; Thu, 30 Jul 2026 16:18:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785428335; cv=none; b=uR7uJz4zEqGd2ZetMT83qXj25HtkshBfihYDkRBNU8nrBHKqbsgdUy8r3O2m4OwDVN+/mPKItoJwW7+FzXEkk+sznNnO5rJK7Ew6ba/nMVty5S5N2KCSBBmuSiioQvS9htXorZAk6kVC/QYuZBStULKJOsafCDiTG9WdCpxjFgA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785428335; c=relaxed/simple; bh=6zU47dNxXJK4csXsnAag2egAas+oLPGACZA5axr2pvA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uoknFed6eI79jfQi7yuGNNkqHbVCkR6dnlKIWH9A8V0EaJesXPVb7D+4gm58avewwiRyr6bAUXeQeABHMIH9pD75hfNRQiUG6LvvKmWc4FPU4Brl4pG/dMmABr3DcSCamU6hDqAuMzzSe6rceg7zh9rimS18en9eSvoZarC4eHk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Az1lLkX6; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Az1lLkX6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4B1DE1F000E9; Thu, 30 Jul 2026 16:18:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1785428333; bh=Jprc5pqm3b5dvzW4LitJQPCPCheluAg4MfnOZJY+Zss=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Az1lLkX6W809GWTYxU61YLc1K/KzkvRJA49m4uuQ1cCJ77fbgeVpLc+Rjk7KIiKIO sOgQ9IdsCv13z5tGcIiiEGST+jnPlCZlPQ2wCi5WK2vjQA1+UdFn/CAHuSCSyMH0gW XT2YWKb7XudAon+QGPF7Lh7k3hkpGnX1kHFLK6Ps= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Rasmus Villemoes , Masami Hiramatsu , Andrew Morton , Sasha Levin Subject: [PATCH 6.6 466/484] bootconfig: do not put quotes on cmdline items unless necessary Date: Thu, 30 Jul 2026 16:16:03 +0200 Message-ID: <20260730141433.609799700@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260730141423.392222816@linuxfoundation.org> References: <20260730141423.392222816@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Rasmus Villemoes [ Upstream commit 212f863fa8811c780abacc1d0404c573fdc0a2de ] 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 Cc: Masami Hiramatsu Signed-off-by: Andrew Morton Stable-dep-of: dec4d8118c17 ("bootconfig: fix NULL-pointer arithmetic in xbc_snprint_cmdline()") Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- init/main.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) --- a/init/main.c +++ b/init/main.c @@ -325,7 +325,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) { @@ -343,8 +343,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;