[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2025071116-pushchair-happening-a4cf@gregkh>
Date: Fri, 11 Jul 2025 14:40:54 +0200
From: Greg KH <gregkh@...uxfoundation.org>
To: Huacai Chen <chenhuacai@...nel.org>
Cc: Huacai Chen <chenhuacai@...ngson.cn>,
Andrew Morton <akpm@...ux-foundation.org>, linux-mm@...ck.org,
Alexander Viro <viro@...iv.linux.org.uk>,
Christian Brauner <brauner@...nel.org>, Jan Kara <jack@...e.cz>,
linux-kernel@...r.kernel.org, stable@...r.kernel.org
Subject: Re: [PATCH] init: Handle bootloader head in kernel parameters
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 <gregkh@...uxfoundation.org> 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@...r.kernel.org
> > > Signed-off-by: Huacai Chen <chenhuacai@...ngson.cn>
> > > ---
> > > 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
Powered by blists - more mailing lists