Received: by 2002:ab2:788f:0:b0:1ee:8f2e:70ae with SMTP id b15csp149357lqi; Wed, 6 Mar 2024 12:42:23 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXvOYWoLo3KLVDx7WGE4LAQ0jqza8l0bLYobXSm1Qa1Wu/PpfwLKN3nbBdivfR30x4Syxu/50hV+z5rih2LFKhvVWa13NdAsSMofxqbAg== X-Google-Smtp-Source: AGHT+IG0v340Xc1UQqkR+B5WfKNh5LAFLOg54Dk+Bzgh73UUhAxVfNxp3eVJ26WFyCrlcVERqB1M X-Received: by 2002:a05:6a00:4b42:b0:6e4:62ed:23c3 with SMTP id kr2-20020a056a004b4200b006e462ed23c3mr19807318pfb.9.1709757742881; Wed, 06 Mar 2024 12:42:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709757742; cv=pass; d=google.com; s=arc-20160816; b=XoSd7FKJ+0MXCPc/ufQFlc+HOYJ9+N7KicoL5HuBQHk443yvluog8Qaj9GHFp8eAdb gV3tl+AEOgIdhT2rMDic0BNTjzZ3/lqL+SSSUnle0dI58VNSfS6yE3gRqvkDj1mMpF6L DwgTobtiYGJ3vT0ufrE3hvmFEQDde34FsgwvaJo9OXOCCIgrlT/PQ80ICtdY7y08ONNQ asKO7IyPgTfsOJInNHnH/wyYDdY3NSS6O0qpbS8P1bFKmd4v3hZJSqYWW53m3DAUPWYq PIDgVv6zoV0mjCrHlhr9RqLxmQfILrT5flk2EqdGrcyr5WzG3WlQ+j1ODtg6CTV5hL68 Tvcw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=XBECof7Fm+h/8lLi0eE/USRHwn75UxGej4/olkyyqnY=; fh=NZ4wU5Sxe+k67+YDK1qqUu0oI2/5gB9xUw0CUkkdAnw=; b=OHaQmCaqBHN1Y+GZINhvhyUapIMeA2QtqM+3gkAmXNoakzGkQYu4IHeQw3Omg5H6Eu GPPQsOVp847xCD0eATUIJzJk5yW2SeCKWr9d9sylQvfHblJBc0uS8wRlVQeHf7r5iJDW gZ3zkBV5aABEw8xrxTpXnmzcW+92NeCM4UhtOi1qNNy5Pg+mG7DttpPY+Mh9c0MZTAnl HOlMcamR+VYLU7dtss0I2awyqjLzPke6MogBTjmtBHQlVIMNyu0bZy/3n2Q61G6sqIZY L0xbkcrGD4x8GHx9FPH6ytCBUhW2+qE21NjSOIgrOdc3ztX1pLAsn4RtfjZ8AD12wAKf RjZQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=CXXCYn+0; arc=pass (i=1 dkim=pass dkdomain=linux-foundation.org); spf=pass (google.com: domain of linux-kernel+bounces-94566-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-94566-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id f12-20020a056a0022cc00b006e55993a954si12800006pfj.382.2024.03.06.12.42.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 12:42:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-94566-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=CXXCYn+0; arc=pass (i=1 dkim=pass dkdomain=linux-foundation.org); spf=pass (google.com: domain of linux-kernel+bounces-94566-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-94566-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 98B42B21CF0 for ; Wed, 6 Mar 2024 20:42:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4C14617551; Wed, 6 Mar 2024 20:42:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="CXXCYn+0" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 69015134BF for ; Wed, 6 Mar 2024 20:42:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709757732; cv=none; b=aFF7X6RKnVghew9I6pWYwJQOjxB80whtIY3+eEiMSqVMJaf2iQq0PbXIeLUkPQ+rDfRFAeyv9t6TwbhWdeECzWuKVCJv197S0ZI03R5Z24tPphw4PgKXsHhpc3xV7BJeaDwCw/bWH/gIWv3Wn4oiw6nJhzKNXpZKcwcoYgqMFFo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709757732; c=relaxed/simple; bh=8QjkGGN56rur3Zd21nSy/XsuEaDgsedBd1S3bKFlFU0=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=JTA27zBpOSBtVHNVtjoZK9zrB1Ijo6sbx19F/XDrzoiX4WCeWHDCeh3p+PzJC5Yr8SZMEAmlF8pyQEDOZVZsE8p9hYmWFTZYPriQ6FGMrpvMPPkr3BgEab7aRz9eMRtZfk8fdDhNRjxfSnJ0nur/PjlvEniMSO5vwr9wEo9oaxs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=CXXCYn+0; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D19ECC433C7; Wed, 6 Mar 2024 20:42:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1709757732; bh=8QjkGGN56rur3Zd21nSy/XsuEaDgsedBd1S3bKFlFU0=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=CXXCYn+0DRw9TwQ+UvHiyx2VWaZ0gl28mmO8VtprvUd4GJBgqWgqN7MefW8nwY6BK e5ZF0XtGmtIQ3kCBnxuzmW8tITG1Bq/QlZlCFse/mJ9YJafeCY5ZCibamGBUOpyuGC 1f4AATCSiL44yozW5VWrQnRO0ZqwLG18MVlgVMNE= Date: Wed, 6 Mar 2024 12:42:11 -0800 From: Andrew Morton To: Rasmus Villemoes Cc: Masami Hiramatsu , linux-kernel@vger.kernel.org Subject: Re: [PATCH] bootconfig: do not put quotes on cmdline items unless necessary Message-Id: <20240306124211.b490ea3c2372d89cff8c287c@linux-foundation.org> In-Reply-To: <20240306122452.1664709-1-linux@rasmusvillemoes.dk> References: <20240306122452.1664709-1-linux@rasmusvillemoes.dk> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Wed, 6 Mar 2024 13:24:52 +0100 Rasmus Villemoes wrote: > 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. > > ... > > --- a/init/main.c > +++ b/init/main.c > @@ -319,12 +319,20 @@ static char xbc_namebuf[XBC_KEYLEN_MAX] __initdata; > > #define rest(dst, end) ((end) > (dst) ? (end) - (dst) : 0) > > +static int has_space(const char *v) > +{ > + for (; *v; v++) > + if (isspace(*v)) > + return 1; > + return 0; > +} Do we already have something which does this? Could do strchr(' ')||strchr('\t') Do we really support tab separation here? I doubt if that gets used or tested much. This function could be __init.