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 0310B1E9919; Thu, 20 Aug 2026 16:35: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=1787243754; cv=none; b=XsRiWeN6QHX1aeyUBa+QBXpETkHVOTnf7s6Ap+buv61TvgfPHzPbKc0ce4aCX8l2qgU/p0I1Ilgoi9dYCMOhY1xs1pIfQ5U7bDkdUctZNdBeIi+g9RWaTn8lEB7a5hJtey9tFt/npXsYMFk/5rFJa6chsadd1Uj7AmtrvMTnZ9I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787243754; c=relaxed/simple; bh=WywFiwUg1/myp5HI6WPl0oHrsvrmbBogseLj1SIuhFo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=g3oq47bd7IZdzR6TpKERMu8UM7SenTJxbkkqFX/BAh81/Lkyn1NfNLaoqE+DnOEyr0s0C7asbykyDzp1dum+ChSYgLJ6IipYkn/loPwvlUsB8pFRHlstuqekZEfub6549RzCk5m6weDTgZr/L51yloXUN6dKXIyFxEKRjnD3VVU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=mYLNOPCl; 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="mYLNOPCl" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5E8661F000E9; Thu, 20 Aug 2026 16:35:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1787243752; bh=e+2a59lo/RuR3yd/Nv7lp91+EMLkRAGH50puHKzdVnU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=mYLNOPCl1G4uh9yMVRmttzy6jBHnHnVKY6z6ds9BiOhwL8jLZ0zZstItNsmnI3EZ6 R0qmAG0W2/DmjY4Ok37UolQsFALbTbMaceKTo+j5zUXEQ2imQnkG+rCRD6acXcM+bZ 1TzWRQzvB2jG+1hdv0sZllg3c8SQodEGLZVJbCb4= 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 5.15 155/272] bootconfig: do not put quotes on cmdline items unless necessary Date: Thu, 20 Aug 2026 16:55:39 +0200 Message-ID: <20260820145235.962303618@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260820145231.229664293@linuxfoundation.org> References: <20260820145231.229664293@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 5.15-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 @@ -328,7 +328,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) { @@ -346,8 +346,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;