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 56F15C83F17 for ; Sun, 13 Jul 2025 08:30:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 81D486B0088; Sun, 13 Jul 2025 04:30:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7CCCD6B0089; Sun, 13 Jul 2025 04:30:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6BA846B008A; Sun, 13 Jul 2025 04:30:45 -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 401676B0088 for ; Sun, 13 Jul 2025 04:30:45 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 843CF587E2 for ; Sun, 13 Jul 2025 08:30:44 +0000 (UTC) X-FDA: 83658570408.20.AB925E3 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf11.hostedemail.com (Postfix) with ESMTP id C0CB740003 for ; Sun, 13 Jul 2025 08:30:42 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=linuxfoundation.org header.s=korg header.b=ZENQaCsy; spf=pass (imf11.hostedemail.com: domain of gregkh@linuxfoundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org; dmarc=pass (policy=none) header.from=linuxfoundation.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1752395442; 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=xt+IfkoE1FTDnboaYnOX0ZQUlRCJfSV6/qrmcB92xDU=; b=jwssLEfQu/wTi+bry6tTGAHfs3wh7oGNikKpOmeSwBt97La4E1y2WZ1KPch3Sc9VFYkkRF tBgmUPSSxIopw2PJ1mLe0IdqfAw0PFv5ec1XBuAatsHPnNYZl5Vhgw/nzNBSrw2i9VMfge xGQNhhomHwGCtuYcf4f0GWupxiez4oI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1752395443; a=rsa-sha256; cv=none; b=Tb36WCNEMp3yGze7BtOcPCVuxTgdTRUD5acd1WII7tseB6MzevaQyZj6ORQmyfxoke84Jj shTJdb7cRexTafNhgTkZqJBeW2+ousSQJViqmO3olHRKIQHPBsYUr3LcLVFr0VTJKGUf+L RW/irjDk5kh24c3X+iYLYNHM0nahrZI= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=linuxfoundation.org header.s=korg header.b=ZENQaCsy; spf=pass (imf11.hostedemail.com: domain of gregkh@linuxfoundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org; dmarc=pass (policy=none) header.from=linuxfoundation.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id C36C95C562D; Sun, 13 Jul 2025 08:30:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2B678C4CEE3; Sun, 13 Jul 2025 08:30:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1752395441; bh=zbQvE2eH5TdCyV51o1wwmhwiDWOwyFQZ33tGrRQNxFk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ZENQaCsyeJPLWmiwvh7Sgctxg1tTr3wrLzFEKlN92XZe/ykgFjC/HWkjEAlIM9Yqv HAgC9m/MKj5MWTZRYIgqWp2Zm2zP9F8RJXiM+KeB6N3T2ZORqUNXnA9H0ulF+YhVqi F8QxA0BxQMfUc+jEqp6HgrxzQkFvO0Ji0jMNPp/g= Date: Sun, 13 Jul 2025 10:30:38 +0200 From: Greg KH To: Huacai Chen Cc: Huacai Chen , Andrew Morton , linux-mm@kvack.org, Alexander Viro , Christian Brauner , Jan Kara , linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH] init: Handle bootloader head in kernel parameters Message-ID: <2025071330-alkalize-bonus-ebec@gregkh> References: <20250711102455.3673865-1-chenhuacai@loongson.cn> <2025071130-mangle-ramrod-38ff@gregkh> <2025071116-pushchair-happening-a4cf@gregkh> <2025071150-oasis-chewy-4137@gregkh> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: C0CB740003 X-Stat-Signature: s4fixzfgrjof5qg9nggmcp35thk9skms X-Rspam-User: X-HE-Tag: 1752395442-445281 X-HE-Meta: U2FsdGVkX1+YIRHz3aVM+M8BlsNeGjo0K3WYQShrQrU3yltr8EJ8p6iHRu9Cc+jb3Kywl6oOGyOSmrISNXHu4JtBSjrMUFG6WxM+UkO+Q9/xXRIWtGcLd/V+9XKGBDAY3KAUsZBGZ3R2F0DrCjqnhyDdbbBv35WjH9Q/XfpR6WpGMsBN7PMLCrHIsgBIc0qKe1F6AGLQDf5lryfyPJhIZkaYS2BU2X/+NTKclYof01v46/KqpJLovin8B2s1fTjAXx41jN3Z03aRfbqunX3HzLuLBIKz3wAlJuYjH8UFYKPnS3uomn3Z+HMJxeYsL8bR00Zc2QfIa8dNhVi7T+WJJp/MNCpIPgiPj9FXFqYLIP6B4ZCkT9jMHZM5CwyhKM846rkwNYN2hyW1gInoXOYDZ6rgWHi6UiZXjoaNYrbjo9AV9eIMWqGrpVOROSlKIGht/AHda9XSzWj89/EP/wGEZf07RFlIOjH5qca5EBL8EyGkIhHh7LUol2/yR3AB/Q8M9sKPp3b3HZ+P/Ptw+UcScy7ILme96/S61t7kc9V+qRlkeCikNRsQsH7sORjSlUuRF2bVAfC1+quo76blp6HFQ2q6K/bZ5Wd5pJDxLD9VRgg/QS36MCGZfnnTBAmnRLP8NrkdU68ZoShm1Q58XE7X1G4nOBGQcCQBcuohYG/WEIpjb1mjRWLeeXrqRH4rybDK3khkadB0WInmJaT+F063fpldLwGLWiDxE7enyIsbItb60+SqgIzj4RyZem784wleQB24Bak3Db/2iEWaIHD9+Jk9nrhRg58u/zs39zOr58Mr4JzHcYPptG/4YZZq7p/hi9E2KlFyXtsn0wQLjg+fTOhCTcfAYSU+QmzOr4HYoSCnSGKDUWQriJPuXzWlXqFSdEzvAnfIjz0UaFSn934b9f9ubde3yhT0E2iLvOYhYw4Y2o60pQQ/H/tVl6Jbn3n1xNtuZPIo/jyyG6NY29R SZfmErnb pQs3jJvPo/P1jeA1m85WzSKXKgiZikM8/5bjaOy67QAEekAazD2eJA1wB9HPmXPHgVmSPZBlz+djzjVbnonJxBGTWh6O4hFBYhHrMJPOi707EZlc5N2ieQcSJLv6lOu1rhjXmzhNqID5xORelyVkzRGxWNzYZuGpEz/8drePfk0b2uftN2KewVEB7BghFqCShPhvt/eJ3K3MsIaQp8KcmJ8ekCXm4egjged8h94ZMrzU4bu1gpTIbRoFP1XVSd6s16EtLMQ7TC571DH7Fkny/eFooXKogfuNoDd3MKeOjTJccLOoNt4pd1UC/xLMO2aNZTF2j4N6I8hepiTZg1ubE+n/wb5qZ43Xz9Sf9nrGALE9LzamUJ0xk9LdKJwvRWYW+l1WHRR/bl/Whx7wR7K5arksFgMEpyE5oq/aLcoxQ0YiwKRKtYoYT9Ij3Tymo54+zHilHIqJ7NCjOPhkj9f0WJ+3W9IfWAqWOtkOY 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 Sat, Jul 12, 2025 at 11:18:44PM +0800, Huacai Chen wrote: > On Fri, Jul 11, 2025 at 9:04 PM Greg KH wrote: > > > > On Fri, Jul 11, 2025 at 08:51:28PM +0800, Huacai Chen wrote: > > > On Fri, Jul 11, 2025 at 8:41 PM 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 PM 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=/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 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. > > > > > > > > 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=(hd0,gpt2)/vmlinuz-6.12.0-84.el10.x86_64 > > > root=UUID=c8fcb11a-0f2f-48e5-a067-4cec1d18a721 ro > > > crashkernel=2G-64G:256M,64G-:512M > > > resume=UUID=1c320fec-3274-4b5b-9adf-a06 > > > 42e7943c0 rhgb quiet > > > > Sounds like a bootloader bug: > > > > $ cat /proc/cmdline > > root=/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=16ccb8b138218d56875051d547af84410d18f9aa > https://cgit.git.savannah.gnu.org/cgit/grub.git/commit/?id=25953e10553dad2e378541a68686fc094603ec54 >From 2005 and 2011? Why have we not had any reports of this being an issue before now? What changed in the kernel recently? > 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/commit/?id=86d1919a4fb0d9c115dd1d3b969f5d1650e45408 So in 2021 we started printing out command line arguments that were "wrong", so is this when everyone noticed that grub was wrong? > 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? > 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? > 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? thanks, greg k-h