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 6A4DAC83F1D for ; Sun, 13 Jul 2025 09:11:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B75096B007B; Sun, 13 Jul 2025 05:11:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B273C6B0088; Sun, 13 Jul 2025 05:11:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A158D6B0089; Sun, 13 Jul 2025 05:11:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 882456B007B for ; Sun, 13 Jul 2025 05:11:39 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 0F31412B846 for ; Sun, 13 Jul 2025 09:11:39 +0000 (UTC) X-FDA: 83658673518.02.2A17858 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf03.hostedemail.com (Postfix) with ESMTP id 072542000B for ; Sun, 13 Jul 2025 09:11:35 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=jeXe2OoW; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf03.hostedemail.com: domain of chenhuacai@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=chenhuacai@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1752397896; a=rsa-sha256; cv=none; b=1EVHDJLh82LU/dsbB8+/5oHUbbJhJ1OavR0od8fdncoXcbsXBpGEDswxUAe/IdSoIIG0xU A9yOE4vlqhs3g8Db0n3XAV5qVQVoOvFBxoVpCFxXiq4vvfPcIeU42e9A2L6kbZscfP8iaU EDyZi3FtsMT3hblf1JSPkFhitZYXQxA= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=jeXe2OoW; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf03.hostedemail.com: domain of chenhuacai@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=chenhuacai@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1752397896; 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=7iZb9LhvR/BZN54VrPtRBMLjJKXlQL4J17gkr+yIhpU=; b=agAR5uJB5yloulSYSCzNoNkSPPS0T9C6IynZhfDOpDua9n/q41TgPUqu9CUa6iFOuDRlZc 81SAfK/jhTNS6qkncKaVNoTGQx8YfMl2y54+wfYryTzvOflbvQKjWhUPu6C9sBLztq3C/8 Pet7C8jOXqH54HfIwgAJyZWp+o916xA= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id ED16B5C5731 for ; Sun, 13 Jul 2025 09:11:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 936A6C4CEFD for ; Sun, 13 Jul 2025 09:11:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752397894; bh=jYc/JBkIqI2qidnuOUAQsyRiugJlGm80lkYZ1ZsmbeA=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=jeXe2OoWP6kja9kGnl3caJLASNYpaeebqKphRQ7PGaDrLjnLVXr+oJ586JN88WqhL zrbyXEdE5XimYiqROmFK0hHXKgFec7Y8EXux2XUzE/zluRU81ea4Ama36IlTdoo5tZ 2l0nNL8wAGxjMdpyGVaZy5+ovTYNsqNL6cWdTxX2Auieiu9t+i9IH9QKXvM91fxu6e QPrKZlvTRfLfh2f2CUO7rNKdZ0eJVzDO1RFFRwE0h2PKmOH3POZLq4laAL1pctuvHw CqRBdiDu1KfWU0XDr+JAm6jEJM9ZBdLST36zjvhN5uEcKZzQt0v59tLTdPsRT/A3Ci AkIqHAstN1JXA== Received: by mail-ed1-f42.google.com with SMTP id 4fb4d7f45d1cf-60700a745e5so6997470a12.3 for ; Sun, 13 Jul 2025 02:11:34 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCVbVJtXBGHCDzMGqrblXlaIEQrTrMc05iUa9uzTTKgpQMZ3xjfAf7OLVaIun9e5J3CBQGbM+U6Ilg==@kvack.org X-Gm-Message-State: AOJu0YzgVyeItBW3WqJ2japGctZ9UfM92/GEpAnMbzWSnB9h6Iwz1RWX K1hRxsRNv96uzK6Y4EugRlqLTpEggCgl1lXvBBuswVuzI+92pzm+vUEfRXBzN5SE/vz2EnH9A5D Eq1uQ6LJ6FOSfkjysy+Bmm0pfGO6RzcI= X-Google-Smtp-Source: AGHT+IFGDEnDkIgL9O5BsubJZOH+0Tc4zaGFNY39k9QQWMzB7p1zAMJ5ZxPdewcj0eP+jmcUKEPKpmXm+6seUoHzW8Y= X-Received: by 2002:a05:6402:210c:b0:608:493a:cccf with SMTP id 4fb4d7f45d1cf-611e84ff961mr8284018a12.30.1752397892987; Sun, 13 Jul 2025 02:11:32 -0700 (PDT) MIME-Version: 1.0 References: <20250711102455.3673865-1-chenhuacai@loongson.cn> <2025071130-mangle-ramrod-38ff@gregkh> <2025071116-pushchair-happening-a4cf@gregkh> <2025071150-oasis-chewy-4137@gregkh> <2025071330-alkalize-bonus-ebec@gregkh> In-Reply-To: <2025071330-alkalize-bonus-ebec@gregkh> From: Huacai Chen Date: Sun, 13 Jul 2025 17:11:20 +0800 X-Gmail-Original-Message-ID: X-Gm-Features: Ac12FXzu6A8q3DyUoYTiY0yMVw2eXUDho_X9QXkQwvYecpmppzfmBhUnmI2iIbE 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: 072542000B X-Stat-Signature: es43chmio4epqswfha5p6ci43itbqsae X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1752397895-615011 X-HE-Meta: U2FsdGVkX1/h7bfGAhSPl0UXKKINvBFBwAUkNgCZ8sbwQ95d9OFpVfwmERHtnh4vQr7cH45BXODxi/GGIACOhg+bORjTRsKtGqCglLcthlCQQ5hBnrbj8TfNJVOvs9gvacVNX70WUVfHg+vDEih1XRYWyXmnQwcWKyuPJMdtRRIW+YLOP1Tves8ZjOcdPOKRuS724KXjHEHIa/vYE+L4HEE/tK+20sYjTCeCUhDllhWvKI6+pv9xxATgx38Wn5eNAYBdxUUPbUNvXXPtDBFrdyjfzIruuk7lUhpZNBzN3F5smnTiHsH3HQ1htGbM8mU5naZYIgexM7JL6manQqWpPIf4ctTPIMVWUQswsRDkCgZ2vSei1nMbSjcIbYVbBOX7g+U4BiBrJNanSHPQIRh57PqsD96fNG707353r0Bbl0GCx9vy44UUjNozhemtXOAPkH0gZV2bmY5/Y5hPcAGLjTEuumf+UPjcJvbaEpdvb0V+TUrYolhRFMB9rqrD7evd2Rb8mDnjj2tqkxnBfOx++vaUzozuLcln/1qopXg+hzrimAQvm5vhP+AEAL3AO+4OFbUjptdjjP4IiPBJRXPB2USMdlugVQ2RiHNHDEGunB6WvkDJbpMng5DfGQFLhjDi9X90fjvzyVOuwPxLJwkK1psZVX5KfA22fNFcVUfKPztXBswFxJ3qM9Kx0PdtEmNFplb01yeaJOg2bFPKwbOBtEYjvx21cCgvC1w+VnBtEt8Bkzr4BDsS4eTqpuMi93JSLpJVGBdtiHjQBim3sQ9Zb+i8CrehZebaRv7uEUPwLA7GtL4TRYS6mPj1/cDHwBg4xxGFaChoS7SPggSPyViEr6hT75T9yzhyHPxzX24Gq+J0iKhXww+cwkHLoBiTw8zqp4d+/NZOIj04Z7Wv9jLHySABGBbt2xYglDihfe2onwOjd7lUDHIoGOKaIjrwJavd/wp/3q/sIJYTTzAY6eu P4SRbyl+ a2l4avE1Kuzgo7qdHBgg463zRHih0mPnr10E9I1DBGX9LaiGL+y+TFwe0yUNwS9bMX8qp5egNs96oSVsRZ13g3lTbEOfIr8oFeJi5AsXhJP3fY3wjKGtwr/6l5z1dQMdnGbkPEPj2iJl9+2CjIMutTJzpwX96HxDCKdsEN827xcK5LJJkPIvEPo3XJjHjegckWBIfH7nGzTkuFEW/za5+km4TIkul3XMZ8Xf6wLjM56c0N+yhGaEqTDSHhDMX6pOnfuNBAZe5gLnf4Zc/eG/lkfRhm0RdZ44X5ojQUyIFTjt6lOvBtYOkwLhRhsDQjzm6vpbzGV+SUoa8UXkQ2M05988J6aKCI+No6bnTTRCN/zVCreqC78SsHUU7pDdMhFvqEO7L5M/GX3OSqxpCY91gq1fEHzf+VjmBwmQZ 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 Sun, Jul 13, 2025 at 4:30=E2=80=AFPM Greg KH wrote: > > On Sat, Jul 12, 2025 at 11:18:44PM +0800, Huacai Chen wrote: > > On Fri, Jul 11, 2025 at 9:04=E2=80=AFPM Greg KH wrote: > > > > > > On Fri, Jul 11, 2025 at 08:51:28PM +0800, Huacai Chen wrote: > > > > 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/vmli= nuz-x.y.z" to > > > > > > > > kernel parameters. But this head is not recognized by the k= ernel so will > > > > > > > > be passed to user space. However, user space init program a= lso doesn't > > > > > > > > recognized it. > > > > > > > > > > > > > > Then why is it on the kernel command line if it is not recogn= ized? > > > > > > UEFI put it at the beginning of the command line, you can see i= t from > > > > > > /proc/cmdline, both on x86 and LoongArch. > > > > > > > > > > Then fix UEFI :) > > > > > > > > > > My boot command line doesn't have that on x86, perhaps you need t= o 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 > > > > > > Sounds like a bootloader bug: > > > > > > $ cat /proc/cmdline > > > root=3D/dev/sda2 rw > > > > > > I suggest fixing the issue there, at the root please. > > Grub pass BOOT_IMAGE for all EFI-based implementations, related commits= of Grub: > > https://cgit.git.savannah.gnu.org/cgit/grub.git/commit/?id=3D16ccb8b138= 218d56875051d547af84410d18f9aa > > https://cgit.git.savannah.gnu.org/cgit/grub.git/commit/?id=3D25953e1055= 3dad2e378541a68686fc094603ec54 > > From 2005 and 2011? Why have we not had any reports of this being an > issue before now? What changed in the kernel recently? As said before, just in some corner cases it causes problems, but corner case doesn't means nothing. > > > Linux kernel treats BOOT_IMAGE as an "offender" of unknown command > > line parameters, related commits of kernel: > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/comm= it/?id=3D86d1919a4fb0d9c115dd1d3b969f5d1650e45408 > > So in 2021 we started printing out command line arguments that were > "wrong", so is this when everyone noticed that grub was wrong? Somebody may think a warning is harmless, somebody thinks a warning means a problem needs to fix. > > > There are user space projects that search BOOT_IMAGE from /proc/cmdline= : > > https://github.com/linuxdeepin/deepin-ab-recovery/blob/master/util.go > > (search getBootOptions) > > https://github.com/linuxdeepin/deepin-ab-recovery/blob/master/main.go > > (search getKernelReleaseWithBootOption) > > What does it use these options for that it can't get from the valid ones > instead? Some projects have fallback methods, some projects don't work, but at least this means some user space programs depend on it already. > > > So, we can say Grub pass BOOT_IMAGE is reasonable and there are user > > space programs that hope it be in /proc/cmdline. > > But who relies on this that never noticed the kernel complaining about > it for the past 4 years? So If I'm the first man who notices this and wants to improve something, then it is my mistake? > > > But BOOT_IMAGE should not be passed to the init program. Strings in > > cmdline contain 4 types: BootLoader head (BOOT_IMAGE, kexec, etc.), > > kernel parameters, init parameters, wrong parameters. > > Then fix grub to not do this. > > > The first type is handled (ignored) by this patch, the second type is > > handled (consumed) by the kernel, and the last two types are passed to > > user space. > > That's not obvious in this patch at all. If you are doing different > things, make it separate patches. > > And again, fix grub. > > > If the first type is also passed to user space, there are meaningless > > warnings, and (maybe) cause problems with the init program. > > So it's been causing problems for all these years (i.e. since 2005)? > > What changed that is causing this to be an issue now, and again, why not > just fix grub? Corner cases have had problems since 2005, and just because they are corner cases, they are not noticed by everyone. But once they are noticed, they need to be fixed. We cannot change Grub (LILO do the same thing) now, because user space relies on it already. Huacai > > thanks, > > greg k-h