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 76402C83F1B for ; Fri, 11 Jul 2025 12:51:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0FAFF6B00A3; Fri, 11 Jul 2025 08:51:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0ACDD6B00A4; Fri, 11 Jul 2025 08:51:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EDC456B00A5; Fri, 11 Jul 2025 08:51:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id D44146B00A3 for ; Fri, 11 Jul 2025 08:51:46 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 25DACC0E5D for ; Fri, 11 Jul 2025 12:51:46 +0000 (UTC) X-FDA: 83651970612.21.6B476A3 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf05.hostedemail.com (Postfix) with ESMTP id 43D3E10000B for ; Fri, 11 Jul 2025 12:51:44 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=G7pACg4A; spf=pass (imf05.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=1752238304; a=rsa-sha256; cv=none; b=b8LzfD86ppxYQfH6EM/nlXEvL8ZS6s+X37s+9LQHXVMSQ3gN9YARkz4BX2DH2EYjryuI2G IfbZHL5xRTbib67XqfQqKscEZZP+G+icg3BJe7qVUxI7pq79v9tgAV6z15Yo0uI+GQpGri SjBiPG0632VTYQneqRZjSaVZIO4z3cw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1752238304; 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=T4093umLtP1EmCePeYujnhwg/Mnu/o6PNxSA9GFskVM=; b=Egl2973CuZroejHXjbcTQeioWqZObcRxe4XvDMIAiM1TlBlmf5LYXaPClhAC4KuLXNp60m hbcXoX66gnVdVtrOjXr8peXxT2Zg73/q+Wo97pDBB48uME02HeP7ZCRvQpbMJstOzqP1V/ VwZorC924dVrLuIigSzOVbYrLlnb1pE= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=G7pACg4A; spf=pass (imf05.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 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 6079B5C70B2 for ; Fri, 11 Jul 2025 12:51:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0C5AEC4CEF7 for ; Fri, 11 Jul 2025 12:51:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752238303; bh=lyUxwBHju02dMiKQLVH2xFYhplRqJaXP98Xc9BmW/VM=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=G7pACg4A5gOwlgYcQ0CRPr+uZxp7vRe8+FNW54nisS6mwXxjP6+SAJlNkzvFYjYVz vwVjlz0I14VpKK0gEXcTn72Xqzepi364oowGr6W3O1sCjBJz8fuUxkt4Hn6bfkzH+4 r0Ec3UQ1jxZNZdfxlw0JtM3v4py/L85TV4WJIzYRdm75fEI3r5yk9glxXXqrMvnIPl 5wpGdMHiWYG7mFlaYeuL0rnNla8j8B9irSDAc8f7yv0JNH4MUKdSk2LQmY4YD759fn 2L0tmuypgd2tdc11BdlPdKOevWQRUrdQ/ACWS9fI4h++63ecMnFk95HIW1n8GAnQIx 2Nmc1bkP2JGdw== Received: by mail-ed1-f53.google.com with SMTP id 4fb4d7f45d1cf-60c4521ae2cso3808029a12.0 for ; Fri, 11 Jul 2025 05:51:42 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCVV1zGiWP9pJPFh2fnWssXMzMyC061jLHxgu1IepXUTKW7cAHKWmCev7hr8gEQxdzALQnTW+zWYGw==@kvack.org X-Gm-Message-State: AOJu0YzrNeCq48n/dLnGys+CAsvnxgb17mzqWo/B2spPcaRlW3TLeekm ual5NKkpPBTtr/PHjHWPSiNn5VIVM37Ipnj9E8Epi/nrgkZ6ONi7AP9U2rxuHtwCpoatay9x6v9 QaFC2q6uMX085JJB9jdJcaTFMFkF8R9I= X-Google-Smtp-Source: AGHT+IFW/bftZomDuupR4W+DSF41mDHFFf4QUZwB/KJ9wARlJtOAWK9Nyp3GY2X97r0qgDp4UX3BbGkhltmoSabmvDg= X-Received: by 2002:a05:6402:5144:b0:5fd:c426:9d17 with SMTP id 4fb4d7f45d1cf-611e84f23ccmr2326985a12.34.1752238301458; Fri, 11 Jul 2025 05:51:41 -0700 (PDT) MIME-Version: 1.0 References: <20250711102455.3673865-1-chenhuacai@loongson.cn> <2025071130-mangle-ramrod-38ff@gregkh> <2025071116-pushchair-happening-a4cf@gregkh> In-Reply-To: <2025071116-pushchair-happening-a4cf@gregkh> From: Huacai Chen Date: Fri, 11 Jul 2025 20:51:28 +0800 X-Gmail-Original-Message-ID: X-Gm-Features: Ac12FXwjmQViTDRFlDw_gjXlsiSf8z8aQReLwHlf5Zckibot1d-vLEa544f80Z4 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-Rspam-User: X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 43D3E10000B X-Stat-Signature: anjup1ex1o4rek4jsg48aec3iwoa4cth X-HE-Tag: 1752238304-657872 X-HE-Meta: U2FsdGVkX19ADyBcoxsOz4HqioY1ZYN6MrXgBpQVbIxzE5mcFarxbpIYMLzwhGIIDDeCa7g4qJh4lcGKOK8I3JchAZ9BiWQ0BMlpWDKhVjBR2RT5bg7M35tTcnWtgLQ1sDVyh64zaqmlixx5rIWRz+I//9yKoYfQDcCl5g/kALehsUVQb7OeTG2XcKgF3aljtC5ED6sBdm65OASDiZDi4haA0K0C+tyEFm4VEoCRIAYNQ49kyB2YyYobZeK9N+PpULun3bZin/AZ7srlTwmMNgFma1LS8HI0w6at00GjibDxi06vg47h5bs1T3NufNxKurlwczdeGv2dBQpxWZ/cu5Z8+0SoSyRWfzQmcX+/r6Hai5SRjAYuM/Y7a6JI2NixDL7pwT/rVA+BrKx4X403IZT7EXyBaFvhjnVZW2OPalUoeOmMsxBD4vL879QOWJYeU3pYfYwydhNPMx6tx14ocWcZjTnleOdt5lYLS76SBck7+N38VSMUBeDIArABX0K2t77Hd8JbvUDztxuOI5gKmGCfghUJXPhpWjiCTca1ZKUqExWQ2zYFqinWw0xA/Abj8hAvLffrizV/u0M7a+N+Y2GrkQpH6xYafO0i+nNntasnGiPo0edfRTNGawgpiH9QcOcnwqnFc8m8uhh48nA3HQru2I4I+W4nwpZrpSNHdFocCY9+aYE0Jgh1vOrraZErWstls1A9B+w498gEAvj/r9aPU4pzPjgZJWaPm+s2qYreDIBgni9iFx9wpgea1qk1zMFvrwKyq4zxxsbcJIS3PisixKCZZ73z+pP/+bLkrquPX9OiGmr8t9dGrzDkMxI8gpaHvd21kjXULDgY97ni5YQriXOxhWHMkZXmtAeGF6bSpSa73qQdZMWNljCd099U5uCh4kYB5fDRyomWv+7J59MZ08nbbT0GzBCbaG9Ebb/vnXJavyOsKqdbrUqBo3N3tOOM6uYtoXo= 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: On Fri, Jul 11, 2025 at 8:41=E2=80=AFPM Greg KH wrote: > > On Fri, Jul 11, 2025 at 08:34:25PM +0800, Huacai Chen wrote: > > 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" to > > > > kernel parameters. But this head is not recognized by the kernel so= will > > > > be passed to user space. However, user space init program also does= n'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. > > Then fix UEFI :) > > My boot command line doesn't have that on x86, perhaps you need to fix > your bootloader? Not only UEFI, Grub also do this, for many years, not now. I don't know why they do this, but I think at least it is not a bug. For example, maybe it just tells user the path of kernel image via /proc/cmdline. [chenhuacai@kernelserver linux-official.git]$ uname -a Linux kernelserver 6.12.0-84.el10.x86_64 #1 SMP PREEMPT_DYNAMIC Tue May 13 13:39:02 UTC 2025 x86_64 GNU/Linux [chenhuacai@kernelserver linux-official.git]$ cat /proc/cmdline BOOT_IMAGE=3D(hd0,gpt2)/vmlinuz-6.12.0-84.el10.x86_64 root=3DUUID=3Dc8fcb11a-0f2f-48e5-a067-4cec1d18a721 ro crashkernel=3D2G-64G:256M,64G-:512M resume=3DUUID=3D1c320fec-3274-4b5b-9adf-a06 42e7943c0 rhgb quiet > > > > > 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 av= oid > > > > such boot warnings: > > > > > > > > Kernel command line: BOOT_IMAGE=3D(hd0,1)/vmlinuz-6.x root=3D/dev/s= da3 ro console=3Dtty > > > > Unknown kernel command line parameters "BOOT_IMAGE=3D(hd0,1)/vmlinu= z-6.x", will be passed to user space. > > > > > > Why is this a problem? Don't put stuff that is not needed on the ker= nel > > > 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. > > Again, fix the bootloader to not do this, why is the kernel responsible > for this? > > What has suddenly changed to now require this when we never have needed > it before? Because init=3D/bin/bash is not a usual use case, so in most cases it is just a warning in dmesg. But once we see it, we need to fix it. > > > > > 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 *para= m, char *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. > > Again, fix the bootloader. But I don't think this is a bootloader bug. > > > > > > > > > /* Handle params aliased to sysctls */ > > > > if (sysctl_is_alias(param)) > > > > @@ -552,6 +553,12 @@ static int __init unknown_bootoption(char *par= am, 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. > > You need to document this way better. > > But again, please just fix your bootloader to not pass on lines to the > kernel that it can not parse. OK, I will update the document, but again, I don't think this is a bootloader bug. Huacai > > thanks, > > greg k-h