Re: [RFC PATCH] x86/Kconfig: Disable KASLR on debug builds

From: Mark Rutland
Date: Mon Dec 04 2023 - 05:42:23 EST


On Thu, Nov 30, 2023 at 01:49:09PM +0100, Borislav Petkov wrote:
> On Thu, Nov 30, 2023 at 01:08:31PM +0100, Peter Zijlstra wrote:
> > Works for me, but I have "nokaslr no_hash_pointers" on all my machines
> > by now. It goes right along with "debug ignore_loglevel
> > sysrq_always_enabled earlyprintk=serial,ttyS0,115200" :-)
>
> Bah, there's cmdline switches. Lemme add them to all my scripts starting
> guests and grub too. Thanks for the hint!
>
> I guess we could still do the Kconfig dependency when we're on new
> machines, without the scripts.
>
> Btw, I'm not the only one who's walked right into this one:
>
> config KCOV
> bool "Code coverage for fuzzing"
>
> ...
>
> If RANDOMIZE_BASE is enabled, PC values will not be stable across
> different machines and across reboots. If you need stable PC values,
> disable RANDOMIZE_BASE.

IIUC that's no longer necessary, and the Kconfig.debug wording is stale.

That wording was introduced in March 2016 as part of the original KCOV support
in commit:

5c9a8750a6409c63 ("kernel: add kcov code coverage")

Later, in December 2016 we made KCOV adjust the address to remove the KASLR
offset in commit:

4983f0ab7ffaad1e ("kcov: make kcov work properly with KASLR enabled")

... so I think that's been stale for ~7 years, and we just forgot to clean up
the Kconfig.debug text.

Mark.