From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C98F9C83F1A for ; Fri, 11 Jul 2025 12:34:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1023A6B00A4; Fri, 11 Jul 2025 08:34:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0DA866B00A5; Fri, 11 Jul 2025 08:34:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0168C6B00A6; Fri, 11 Jul 2025 08:34:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id E2E156B00A4 for ; Fri, 11 Jul 2025 08:34:43 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 844101A0DC2 for ; Fri, 11 Jul 2025 12:34:43 +0000 (UTC) X-FDA: 83651927646.22.799A82D Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf15.hostedemail.com (Postfix) with ESMTP id 8403CA0003 for ; Fri, 11 Jul 2025 12:34:41 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=EFMWAsX0; spf=pass (imf15.hostedemail.com: domain of chenhuacai@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=chenhuacai@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1752237281; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=c5+7Ur/sg108xdTkbv/DZMRZzjsyEIR1ci7nvL9gIHM=; b=JpEazmB35VBndCIQKqCWqd/JOQmJhehurm7AAnLRglyOLsY3BJmyGNPFgBiq+za27066U4 6ofO6tGegnkE1ivNzV0RjLBqW3dQFDvgPBmdxNthqOJ5VVyI/xDfC+kHGeK4ho+ZA44KDZ py5GI4u/npehXtQp1SRFk3vWoKyCkok= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=EFMWAsX0; spf=pass (imf15.hostedemail.com: domain of chenhuacai@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=chenhuacai@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1752237281; a=rsa-sha256; cv=none; b=gYCQ1ky88/VSNiNaJf6xED8+jJSjgiu329qBUAIBRvVrYar1tB+fLO6F8InI48Vlfc9V6m 7MaLkuCCEXNED+edQaIT4aF1dkYbijoL009DuyDENl6mi5PcCd+d8UIDCmILa5mcEht9O/ kI+uBdaY+wHiaTwma3lsrvGxzVnilFs= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 82FFF5C7056 for ; Fri, 11 Jul 2025 12:34:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 46EE7C4AF09 for ; Fri, 11 Jul 2025 12:34:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752237280; bh=iPzBUak9frIQPxX1OSSUONLfOETT41XmEQPiZTZmh90=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=EFMWAsX0WDIhXrSqySOFTtd74au8J70vA2APRHzPRgkGeOKVAf7UP/cYx/ndgq86e 9QmhwR2dEuSegz7my3puu2hUendHXmgBukaue/oMYFibCQP54iVLGPMvyyFSbt2iFM cuVcNHfaiL66rhJMLw3GoNLglnaEEGnf3cFQiWvKGkPoHPyS+G6iNlkOAscu8STCp9 eX59TUAzVP0DgZPyRPIWl14+wxtJ56NtV8rY0MPPiRKP0Do6EAJ6UnW4C1GLamKY2S BS0ZKl6WJnRVjFSvzD8AYspsFlBi6d1Ibyu8ObFoiLHEe9Mo4eXC1crjxhgfNQQN1F WkVty5MGtoIyw== Received: by mail-ed1-f54.google.com with SMTP id 4fb4d7f45d1cf-60c60f7eeaaso3090897a12.0 for ; Fri, 11 Jul 2025 05:34:40 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCXJnY5lrIdJVc4QYVfVxIzWaadaLIxL0YWnaSwSIiv+g7qRB9EuHAE2TgsG7O+4hlDN6/8s8lbcgw==@kvack.org X-Gm-Message-State: AOJu0YxINaezAHdPk82E9cYKGeI8YZBjKWQPJZsPhc774V+bOWcenqxh H5q0qnz44mPY/lo2ZB0Zr8Cbp4etjzxsq3gm0SHImFygv9MeQG0ZJHnruARxuHb9NnysIguZUR7 eIrI3tD+g5Nt8UW0hoauWFdI/MERxEi0= X-Google-Smtp-Source: AGHT+IEluutpYJhPNDQCqi/aWbbEENSWhbRoj7AH++W2t36i/1/OdG3p5utN3ZMcp6elFijTRbgenLzeZgoi4oOtBwo= X-Received: by 2002:a05:6402:1e92:b0:607:32e8:652 with SMTP id 4fb4d7f45d1cf-611e84997a1mr2486337a12.19.1752237278630; Fri, 11 Jul 2025 05:34:38 -0700 (PDT) MIME-Version: 1.0 References: <20250711102455.3673865-1-chenhuacai@loongson.cn> <2025071130-mangle-ramrod-38ff@gregkh> In-Reply-To: <2025071130-mangle-ramrod-38ff@gregkh> From: Huacai Chen Date: Fri, 11 Jul 2025 20:34:25 +0800 X-Gmail-Original-Message-ID: X-Gm-Features: Ac12FXwdjQ3g5zxmjsCe_SAgVWzfc3x861r0WM0FTkTcHpT0fUNhHKvncL8LWXI Message-ID: Subject: Re: [PATCH] init: Handle bootloader head in kernel parameters To: Greg KH Cc: Huacai Chen , Andrew Morton , linux-mm@kvack.org, Alexander Viro , Christian Brauner , Jan Kara , linux-kernel@vger.kernel.org, stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 8403CA0003 X-Stat-Signature: 4us1tq5wd5yr9y781wd85u15soxt3b1p X-Rspam-User: X-Rspamd-Server: rspam07 X-HE-Tag: 1752237281-100522 X-HE-Meta: U2FsdGVkX18xeAOSZ/qgJaNCLy5OP3e0k1IW5UUOmjzh9/8gjM1/7pbfBXfKdZmCfVfSaYoe51C6b1hsy+HJ+LzoBLXvDQLyFjhDdwXp6epFLa8DnF92Ec3nHi6DHrsmd9j580d2+uDggP0CebH2WmwqJSnrAnBLxPI5jgZ3ybtSZiko+pf3z//RKTS6AVbdn+4J3dBs2IK9ERbduqWNK6kXuh4NU3im1rzlvcP5GuAVIaJjNUtWHygb6DgjXduUc+bxbE5yq1RpPUvDi+9tZDNbu37ovV7ezTouw4/QXu6aJSncZJJdjFPtYaczjcL90ald0myJZZU6c+bpyFHmx5/vMYKQEX1GpGdh2cYXfsNTqN9trNY4W2SSSwWhIoGXhQPOc8IiOXFcIB3upTjcMlvN+ZNHTHJALfFSqMjWPKfDSVt4tT1GN0IZGX6HuSmpOefBHHvjnmwpMcQH23vSb/m9PUYEw87cUeocg4ZL8KzSxPxCzRImNi2qEuDAqW46u7jEyUl/4TznW3n/eT8LI6GKVomgdntnVN8Q23ABVaGJ1/Cg7GjGyueLPFjgd0Pv1AB4DYb3HKfTys6eS6hhpyk5LoH+V9nrxFwS17xJaCOFiVJm6bMFKmjvYV/8YrSA452Uxmpanw6wTqQBIt05+GK1svop0K+Ks0UV6C4ku/a0oCk1e/antSAH8KDqCjuwbp3wdMCnQcLF38UWPtA+fY34ZXlXuQcC/knrmhPXoVG/NJL0BbMgpPwmDgY5BfUzYDpWhC6Bl6Nws/AoOodPynwzVemXrAvbrJf8OTQyvFK4xLqII2w236IOsa1VDYjTUAcwEvPKyOGNgXRB7W7NhB8UiOLuZakNy8zTI+ZGRDgNOzRFFDYe9UKsK/1G33++99JGMCSLhoVg50BK5LHPqrar1n9hDEx+T4MAg74O126puC51k/Hh7zjAqp6BuLtN7lTWBqbmQFIRCu8FL9A egT+cS0K GuscFa/U24AfqKe4EGP4s3QLNNVDimHQY9jgu/U0g3eqrVncQcDvPGLdKDls0ZB5oYiOdvuvgUKfGGqKsmAfYMGivRLjF71wULOY7xM6224oV7rra57fIY7UYA76Xm6+mefdvf7ukBiH6L1C6VSPG1TcmbTk9+bz1bcamw0xE1oWDnOtlKjQ0XpIlVlAQSaYtDphgqs/3eJF6Ntl5JddVFVuZNuq+osLH//YvV4S2mtOaXNU/HAR/w6vZ4/TdxBBXVrPknVpjxrBQFVS/CmInak/SO14eIlltaYhb58BQ0AuBU0wfj3FfnF6ZIPFj/hHfyJ+IZm2Md7qXSTfi09upYQtbhs8bzaC8CrHf+hC9kocdASI= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Hi, Greg, On Fri, Jul 11, 2025 at 7:06=E2=80=AFPM Greg KH wrote: > > On Fri, Jul 11, 2025 at 06:24:55PM +0800, Huacai Chen wrote: > > BootLoader may pass a head such as "BOOT_IMAGE=3D/boot/vmlinuz-x.y.z" t= o > > kernel parameters. But this head is not recognized by the kernel so wil= l > > be passed to user space. However, user space init program also doesn't > > recognized it. > > Then why is it on the kernel command line if it is not recognized? UEFI put it at the beginning of the command line, you can see it from /proc/cmdline, both on x86 and LoongArch. > > > KEXEC may also pass a head such as "kexec" on some architectures. > > That's fine, kexec needs this. > > > So the the best way is handle it by the kernel itself, which can avoid > > such boot warnings: > > > > Kernel command line: BOOT_IMAGE=3D(hd0,1)/vmlinuz-6.x root=3D/dev/sda3 = ro console=3Dtty > > Unknown kernel command line parameters "BOOT_IMAGE=3D(hd0,1)/vmlinuz-6.= x", will be passed to user space. > > Why is this a problem? Don't put stuff that is not needed on the kernel > command line :) Both kernel and user space don't need it, and if it is passed to user space then may cause some problems. For example, if there is init=3D/bin/bash, then bash will crash with this parameter. > > > > > Cc: stable@vger.kernel.org > > Signed-off-by: Huacai Chen > > --- > > init/main.c | 7 +++++++ > > 1 file changed, 7 insertions(+) > > > > diff --git a/init/main.c b/init/main.c > > index 225a58279acd..9e0a7e8913c0 100644 > > --- a/init/main.c > > +++ b/init/main.c > > @@ -545,6 +545,7 @@ static int __init unknown_bootoption(char *param, c= har *val, > > const char *unused, void *arg) > > { > > size_t len =3D strlen(param); > > + const char *bootloader[] =3D { "BOOT_IMAGE", "kexec", NULL }; > > You need to document why these are ok to "swallow" and not warn for. Because they are bootloader heads, not really a wrong parameter. We only need a warning if there is a wrong parameter. > > > > > > /* Handle params aliased to sysctls */ > > if (sysctl_is_alias(param)) > > @@ -552,6 +553,12 @@ static int __init unknown_bootoption(char *param, = char *val, > > > > repair_env_string(param, val); > > > > + /* Handle bootloader head */ > > Handle it how? argv_init and envp_init arrays will be passed to userspace, so just return early (before argv_init and envp_init handling) can avoid it being passed. Huacai > > confused, > > greg k-h