Re: [PATCH] kaslr: x86: fixes log message nokaslr

From: Borislav Petkov
Date: Sun Mar 31 2024 - 16:28:52 EST


On Sun, Mar 31, 2024 at 10:05:46PM +0200, Mahmoud Younes wrote:
> Unknown kernel command line parameters nokaslr message will be printed
> to kernel log buffer if nokaslr option exists in boot command line.
> nokaslr gets consumed earlier and this message becomes confusing.
> impact is that user gets confused whether kaslr is enabled or not.

Well, my dmesg has here:

---
..
trampoline_32bit: 0x0000000000000000


KASLR disabled: 'nokaslr' on cmdline.


Decompressing Linux... Parsing ELF... No relocation needed... done.
..
---

so the notification for the user is there.

> Signed-off-by: Mahmoud Younes <m.younesbadr@xxxxxxxxx>
> ---
> arch/x86/mm/kaslr.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/arch/x86/mm/kaslr.c b/arch/x86/mm/kaslr.c
> index 37db264866b6..a62cb0675e22 100644
> --- a/arch/x86/mm/kaslr.c
> +++ b/arch/x86/mm/kaslr.c
> @@ -179,3 +179,9 @@ void __meminit init_trampoline_kaslr(void)
> __pgd(_KERNPG_TABLE | __pa(pud_page_tramp));
> }
> }
> +
> +static int __init parse_nokaslr(char *_)
> +{
> + return 0;
> +}
> +early_param("nokaslr", parse_nokaslr);

This piece of code without any comments explaining why it is there is
not less confusing to whoever stares at it.

I'd prefer if print_unknown_bootoptions() would filter out those options
which are parsed earlier and not warn about them instead of having such
dummy stubs.

Thx.

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette