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 6D5DFC83F1A for ; Fri, 11 Jul 2025 12:41:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C867F6B00A4; Fri, 11 Jul 2025 08:41:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C578E6B00A5; Fri, 11 Jul 2025 08:41:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B93F86B00A6; Fri, 11 Jul 2025 08:41:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id A8BBD6B00A4 for ; Fri, 11 Jul 2025 08:41:05 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 42BDF160DCB for ; Fri, 11 Jul 2025 12:41:05 +0000 (UTC) X-FDA: 83651943690.07.2B19D45 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf25.hostedemail.com (Postfix) with ESMTP id 78845A000B for ; Fri, 11 Jul 2025 12:41:03 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=linuxfoundation.org header.s=korg header.b=uVow4T2a; spf=pass (imf25.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=1752237663; 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=Nf20an07mP7AZVYR8R/d+ceMpQEN5jfnBYlqB2EMr4o=; b=h2sgKoAWTlQJ2mwGV9W3XARuN6No2KBvYgDqjE4jNNSCipzDhwF4JWrJPrs98e8WxLBMSW 5jcrBeyLY6rz4yicoK7iOAru5GMdDrgK57GNcP7SogSCdnJUk/0uL4J0SwO5Zo7GSBG3eJ uUKTBPJFq2K64J17MpMvT1TM7lopFrY= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=linuxfoundation.org header.s=korg header.b=uVow4T2a; spf=pass (imf25.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1752237663; a=rsa-sha256; cv=none; b=kr0xIqdPgTOzdfHD79xLvGhjuE+DLjGmvmNky7mPugKGraKU0qG1rA4O5I/U3doF+5sTGb nHe5JXhZaNpfAIa8ATqcQRIi80kqqbtL+z00Y1aK52k5+RLChXF7UMTTvFugCrsEwK38DR W8UWxAs5/mZMP2aHwHhFuUcCWnJ2rK4= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 9B6EA5C707A; Fri, 11 Jul 2025 12:41:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BFBDBC4CEED; Fri, 11 Jul 2025 12:41:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1752237662; bh=ZY/3jhhQdoYpMzj9GfQknWGqsGqw2sazOyOKr5CRDvA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=uVow4T2adzLEVIod2EBHm1qDxHBcgYCw8wBhok7q3V/qPxwbsc7IXI/pQ1rkTErXy HBU5MbXB+cpcCSlrFdVHC6bL6EdbJDBtDKqD0RdLIspNWGfdk1z0RASrTk7CInnBd4 oRuPdbViCeT6AcdxS6AIUziaAeWg25pIaX8QlVZg= Date: Fri, 11 Jul 2025 14:40:54 +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: <2025071116-pushchair-happening-a4cf@gregkh> References: <20250711102455.3673865-1-chenhuacai@loongson.cn> <2025071130-mangle-ramrod-38ff@gregkh> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Rspam-User: X-Rspamd-Queue-Id: 78845A000B X-Rspamd-Server: rspam09 X-Stat-Signature: cynzgdo8h65591enr1ci8pwcw84bjyh6 X-HE-Tag: 1752237663-379259 X-HE-Meta: U2FsdGVkX1+7I1zXWKc5sJRjLu4mW5LHcrG2EQKNufpjDL3y+Pd7pS/JK1J54U+r6JcsWTav5fJA0iytE7hTt1tYYgxrMC9+W3HFjG8jbklHkvugNWpFm0Z9wZatYxlQwMxYpnSUwROfmCc9nUQfxDXZmAe8mQGjwGxeh9zVNxTAxgiCjwhUBd19onPgZCcb+4EFWS973N9Fvxvm8UYpy6/yqDapOgSRRCiQ/AB+T4teW64V6r4M92vNRsWOqrlkr9uA94TKPbE19WTtyfQHjmsOMmfn/FiBI/XnmmdZAENSeTZmYeKqpkqA75xnfB9ShsbwNfTDw/0UaJXaD8cZOWi6wCYA6AUGZMU6MCdjsntiPvs0sDxDKmsfJv/RKBOrrBa7f3+ugVuUv7eG4+NuOllUirReXxTDbnViIHfydv9UhyLZAFG3vPtJZBSZFS3Bsi1kbvbJd9BBr9hor+2xyOrZx8rf7qzyx41n18tNz42mtNvq4p+Nya7We994qoOnBa01kOUArgKkDHn4DSoxIdn0ELqC9dgEfKm/M3ur3PEzgwsqHmbFpyj2+nzotQUFehG3MNQdg51iO1zvuwgGFzw9yREx/3o6d0FUoz6+xNiqJ9PibESqVU4ePDGPF0r0DpPphRHnFjn02lqFZmB1qaz3QjisWOZ/O+ZwE0sJjqI1kWJJwwbovCzLGPwC+DaWrmSclOYntuDyBKMN7RKmvYE+lb7Dlf8Ym5rxo9j3dQw/tJDYZBGtdtppRupimRBv9igSFgGisDMmbwSbCdgA5XXnxaSmY4FdZCttiz3JE3mWCxNkwwgSSciCp6DN1ilSgdv+v48bfG+vTZVvhATK23k3xofEkUfYwBQ0TbCWTtJpPrdB+Tc6VRdX5ctJTpf+l/PQ7tKko1RacBn1wzs0SmaDclKgJazMAGYfGPiUTSjYGxWvY3S7eeC+Cq/+EdsY+wP6BaqJ5j/ad+zB0SF fK4FdFMJ 4hYTi7hDdkrZeSoold0UciOlz7lCej//Xiz77y0DRRWH7Mgy8e8E7v11eVLMamA+miNeokVawb+owXbIJTJbVNEb6bp+w8j7WbmVuhmCMUcBikmj9QxaDUqdqr8+SGarcnVwKFvASoDvZ1kTMiksWn5RTqqiYINijJLZtueVFMfqmRiylJkSr5tNfMniX1EnwrODIjTe7iMB1sviH32KVFfrqYP9VFLGIiY6A3JduMyjmKcrpUDMy0WyidXHTYihnUgLD0C6ASck/3nKyqb8Xu5ry4mROHF/1U2ApD0rwJ7Zbm4Xhcno0/7/5irSYAp6V9f5x46/FdzGbuHCrEcf6rrMpw0YMQKDxUJXG2xV1cFmflmFNv7s9Vt/xJGTTukuhET94ovGXd2LOH9DixW0auj6HD9uOe9yfAQhirM9QJNWFfuw= 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 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? > > > 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=(hd0,1)/vmlinuz-6.x root=/dev/sda3 ro console=tty > > > Unknown kernel command line parameters "BOOT_IMAGE=(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=/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? > > > 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, char *val, > > > const char *unused, void *arg) > > > { > > > size_t len = strlen(param); > > > + const char *bootloader[] = { "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. > > > > > > /* 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. 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. thanks, greg k-h