security/Kconfig.hardening | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Currently randstruct does not support rust so we have Kconfig dependencies
which prevent rust being enabled when randstruct is. Unfortunately this
prevents rust being enabled in allmodconfig, our standard coverage build.
randstruct gets turned on by default, then the dependency on !RANDSTRUCT
causes rust to get disabled.
Work around this by disabling randstruct by default if we have a usable
rust toolchain and rust support for the architecture, circular
dependencies prevent us directly depending on !RUST. This means we might
end up with a configuration that disables both rust and randstruct but
hopefully it's more likely go give the expected result.
Signed-off-by: Mark Brown <broonie@kernel.org>
---
Changes in v3:
- Rebase onto v7.2-rc1.
- Link to v2: https://patch.msgid.link/20260605-rust-reverse-randstruct-dep-v2-1-93d38023b6f9@kernel.org
Changes in v2:
- Add a HAVE_RUST in there too.
- Link to v1: https://patch.msgid.link/20260605-rust-reverse-randstruct-dep-v1-1-45ce9ee8d0d1@kernel.org
---
security/Kconfig.hardening | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/security/Kconfig.hardening b/security/Kconfig.hardening
index 6923036e1a2f..81c81ad983ad 100644
--- a/security/Kconfig.hardening
+++ b/security/Kconfig.hardening
@@ -278,7 +278,7 @@ config CC_HAS_RANDSTRUCT
choice
prompt "Randomize layout of sensitive kernel structures"
- default RANDSTRUCT_FULL if COMPILE_TEST && (GCC_PLUGINS || CC_HAS_RANDSTRUCT)
+ default RANDSTRUCT_FULL if !(RUST_IS_AVAILABLE && HAVE_RUST) && COMPILE_TEST && (GCC_PLUGINS || CC_HAS_RANDSTRUCT)
default RANDSTRUCT_NONE
help
If you enable this, the layouts of structures that are entirely
---
base-commit: dc59e4fea9d83f03bad6bddf3fa2e52491777482
change-id: 20260605-rust-reverse-randstruct-dep-5a504c861128
Best regards,
--
Mark Brown <broonie@kernel.org>
--
Mark Brown <broonie@kernel.org>
On Wed, 05 Aug 2026 18:02:43 +0100, Mark Brown wrote:
> Currently randstruct does not support rust so we have Kconfig dependencies
> which prevent rust being enabled when randstruct is. Unfortunately this
> prevents rust being enabled in allmodconfig, our standard coverage build.
> randstruct gets turned on by default, then the dependency on !RANDSTRUCT
> causes rust to get disabled.
>
> Work around this by disabling randstruct by default if we have a usable
> rust toolchain and rust support for the architecture, circular
> dependencies prevent us directly depending on !RUST. This means we might
> end up with a configuration that disables both rust and randstruct but
> hopefully it's more likely go give the expected result.
>
> [...]
Applied to for-next/hardening, thanks!
[1/1] hardening: Default randstruct off with rust for better allmodconfig support
https://git.kernel.org/kees/c/3844a38c9c4a
Take care,
--
Kees Cook
On Fri, Aug 21, 2026 at 7:36 PM Kees Cook <kees@kernel.org> wrote: > > Applied to for-next/hardening, thanks! In case you want it (I mentioned this in previous versions but I think I didn't give the tag explicitly, sorry): Acked-by: Miguel Ojeda <ojeda@kernel.org> Typo: "likely go give" -> to I assume people does test (and enable) randstruct elsewhere, so this likely will catch more issues at build time in linux-next, even if it feels bad to lose the other coverage. Thanks! Cheers, Miguel
On Wed, Aug 5, 2026 at 1:02 PM Mark Brown <broonie@kernel.org> wrote: > > Currently randstruct does not support rust so we have Kconfig dependencies > which prevent rust being enabled when randstruct is. Unfortunately this > prevents rust being enabled in allmodconfig, our standard coverage build. > randstruct gets turned on by default, then the dependency on !RANDSTRUCT > causes rust to get disabled. > > Work around this by disabling randstruct by default if we have a usable > rust toolchain and rust support for the architecture, circular > dependencies prevent us directly depending on !RUST. This means we might > end up with a configuration that disables both rust and randstruct but > hopefully it's more likely go give the expected result. > > Signed-off-by: Mark Brown <broonie@kernel.org> > --- > Changes in v3: > - Rebase onto v7.2-rc1. > - Link to v2: https://patch.msgid.link/20260605-rust-reverse-randstruct-dep-v2-1-93d38023b6f9@kernel.org > > Changes in v2: > - Add a HAVE_RUST in there too. > - Link to v1: https://patch.msgid.link/20260605-rust-reverse-randstruct-dep-v1-1-45ce9ee8d0d1@kernel.org > --- > security/Kconfig.hardening | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) FYI, I believe Kees has been away from email for a bit, but my understanding is that will be changing soon. > diff --git a/security/Kconfig.hardening b/security/Kconfig.hardening > index 6923036e1a2f..81c81ad983ad 100644 > --- a/security/Kconfig.hardening > +++ b/security/Kconfig.hardening > @@ -278,7 +278,7 @@ config CC_HAS_RANDSTRUCT > > choice > prompt "Randomize layout of sensitive kernel structures" > - default RANDSTRUCT_FULL if COMPILE_TEST && (GCC_PLUGINS || CC_HAS_RANDSTRUCT) > + default RANDSTRUCT_FULL if !(RUST_IS_AVAILABLE && HAVE_RUST) && COMPILE_TEST && (GCC_PLUGINS || CC_HAS_RANDSTRUCT) > default RANDSTRUCT_NONE > help > If you enable this, the layouts of structures that are entirely > > --- > base-commit: dc59e4fea9d83f03bad6bddf3fa2e52491777482 > change-id: 20260605-rust-reverse-randstruct-dep-5a504c861128 -- paul-moore.com
© 2016 - 2026 Red Hat, Inc.