Re: [PATCH] init: Print out unknown kernel parameters

From: Andrew Halaney
Date: Tue May 04 2021 - 11:26:27 EST


On Tue, May 04, 2021 at 05:00:51PM +0200, Borislav Petkov wrote:
> On Mon, May 03, 2021 at 06:46:06PM -0400, Steven Rostedt wrote:
> > Note, the issue this is trying to solve is to catch "typos" when someone
> > adds a parameter. Perhaps we should add a parameter called "check" and/or a
> > config option to always check.
>
> Well, actually, you want this checking to always happen and
> unconditionally at that.
>
> The fact that we cannot differentiate between params given to init vs
> mistyped params, makes it harder to solve elegantly.
>
I tend to agree, while the "debug" option Randy mentioned gives you the
same info, I lean towards notifying about any unrecognized parameter
personally in an unconditional manner that is clearly mentioning your
command line arguments - it is a bit round about to have to find them
from init. Definitely a matter of opinion, but with the kernel having
specific ways to denote init destined parameters (anything after "--") I
think an unconditional message is acceptable.

> > > > +void print_unknown_bootoptions(void)
>
> static
>
Good catch, will fix this in v2 - thank you!

> > > > +{
> > > > + const char *const *p;
> > > > +
> > > > + if (panic_later || (!argv_init[1] && !envp_init[2]))
> > > > + return;
> > > > +
> > > > + pr_notice("Unknown command line parameters:\n");
> > > > + for (p = &argv_init[1]; *p; p++)
> > > > + pr_notice(" %s\n", *p);
> > > > + for (p = &envp_init[2]; *p; p++)
> > > > + pr_notice(" %s\n", *p);
> > > > +}
> >
> > Perhaps make this one line, like "Kernel command line:" has.
>
> Yap, only one newline at the end pls.
>
I'm outvoted, will adjust to a single line!

> --
> Regards/Gruss,
> Boris.
>
> SUSE Software Solutions Germany GmbH, GF: Felix Imendörffer, HRB 36809, AG Nürnberg
>

Thanks,
Andrew