* [PATCH v4] hardening: Default randstruct off with rust for better allmodconfig support
@ 2026-09-01 22:50 Mark Brown
2026-09-01 22:59 ` Miguel Ojeda
2026-09-01 23:06 ` Kees Cook
0 siblings, 2 replies; 5+ messages in thread
From: Mark Brown @ 2026-09-01 22:50 UTC (permalink / raw)
To: Kees Cook, Gustavo A. R. Silva, Paul Moore, James Morris,
Serge E. Hallyn, Miguel Ojeda, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Danilo Krummrich
Cc: linux-hardening, linux-security-module, linux-kernel,
rust-for-linux, Mark Brown
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 v4:
- Rebase onto v7.3-rc1.
- Link to v3: https://patch.msgid.link/20260702-rust-reverse-randstruct-dep-v3-1-e4e09c50014e@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: cee9395acd8043be0644b25c34bfa86623f2b935
change-id: 20260605-rust-reverse-randstruct-dep-5a504c861128
Best regards,
--
Mark Brown <broonie@kernel.org>
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v4] hardening: Default randstruct off with rust for better allmodconfig support
2026-09-01 22:50 [PATCH v4] hardening: Default randstruct off with rust for better allmodconfig support Mark Brown
@ 2026-09-01 22:59 ` Miguel Ojeda
2026-09-01 23:07 ` Kees Cook
2026-09-01 23:07 ` Mark Brown
2026-09-01 23:06 ` Kees Cook
1 sibling, 2 replies; 5+ messages in thread
From: Miguel Ojeda @ 2026-09-01 22:59 UTC (permalink / raw)
To: Mark Brown
Cc: Kees Cook, Gustavo A. R. Silva, Paul Moore, James Morris,
Serge E. Hallyn, Miguel Ojeda, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Danilo Krummrich, linux-hardening,
linux-security-module, linux-kernel, rust-for-linux
On Wed, Sep 2, 2026 at 12:52 AM 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>
I thought this was already applied:
https://git.kernel.org/kees/c/3844a38c9c4a
https://lore.kernel.org/rust-for-linux/178733378275.2181196.3186172911325132761.b4-ty@kernel.org/
But it doesn't seem to be in -next -- that branch isn't merged there I think.
Cheers,
Miguel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v4] hardening: Default randstruct off with rust for better allmodconfig support
2026-09-01 22:59 ` Miguel Ojeda
@ 2026-09-01 23:07 ` Kees Cook
2026-09-01 23:07 ` Mark Brown
1 sibling, 0 replies; 5+ messages in thread
From: Kees Cook @ 2026-09-01 23:07 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Mark Brown, Gustavo A. R. Silva, Paul Moore, James Morris,
Serge E. Hallyn, Miguel Ojeda, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Danilo Krummrich, linux-hardening,
linux-security-module, linux-kernel, rust-for-linux
On Wed, Sep 02, 2026 at 12:59:59AM +0200, Miguel Ojeda wrote:
> On Wed, Sep 2, 2026 at 12:52 AM 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>
>
> I thought this was already applied:
>
> https://git.kernel.org/kees/c/3844a38c9c4a
>
> https://lore.kernel.org/rust-for-linux/178733378275.2181196.3186172911325132761.b4-ty@kernel.org/
>
> But it doesn't seem to be in -next -- that branch isn't merged there I think.
I applied it but the push broke. I've re-arranged things now and push
it; I'll get this sent to Linus this week :)
--
Kees Cook
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v4] hardening: Default randstruct off with rust for better allmodconfig support
2026-09-01 22:59 ` Miguel Ojeda
2026-09-01 23:07 ` Kees Cook
@ 2026-09-01 23:07 ` Mark Brown
1 sibling, 0 replies; 5+ messages in thread
From: Mark Brown @ 2026-09-01 23:07 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Kees Cook, Gustavo A. R. Silva, Paul Moore, James Morris,
Serge E. Hallyn, Miguel Ojeda, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Danilo Krummrich, linux-hardening,
linux-security-module, linux-kernel, rust-for-linux
[-- Attachment #1: Type: text/plain, Size: 997 bytes --]
On Wed, Sep 02, 2026 at 12:59:59AM +0200, Miguel Ojeda wrote:
> On Wed, Sep 2, 2026 at 12:52 AM Mark Brown <broonie@kernel.org> wrote:
> > 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.
> I thought this was already applied:
> https://git.kernel.org/kees/c/3844a38c9c4a
> https://lore.kernel.org/rust-for-linux/178733378275.2181196.3186172911325132761.b4-ty@kernel.org/
> But it doesn't seem to be in -next -- that branch isn't merged there I think.
Yes, I had thought I'd seen something saying it was applied but as you
did I checked -next, didn't find it and figured I must have been
confused. The link in the mail above to the commit says it's missing
too.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v4] hardening: Default randstruct off with rust for better allmodconfig support
2026-09-01 22:50 [PATCH v4] hardening: Default randstruct off with rust for better allmodconfig support Mark Brown
2026-09-01 22:59 ` Miguel Ojeda
@ 2026-09-01 23:06 ` Kees Cook
1 sibling, 0 replies; 5+ messages in thread
From: Kees Cook @ 2026-09-01 23:06 UTC (permalink / raw)
To: Gustavo A. R. Silva, Paul Moore, James Morris, Serge E. Hallyn,
Miguel Ojeda, Boqun Feng, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
Danilo Krummrich, Mark Brown
Cc: Kees Cook, linux-hardening, linux-security-module, linux-kernel,
rust-for-linux
On Tue, 01 Sep 2026 23:50:02 +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-linus/hardening, thanks!
[1/1] hardening: Default randstruct off with rust for better allmodconfig support
https://git.kernel.org/kees/c/2625480a1bf7
Take care,
--
Kees Cook
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-09-01 23:07 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-01 22:50 [PATCH v4] hardening: Default randstruct off with rust for better allmodconfig support Mark Brown
2026-09-01 22:59 ` Miguel Ojeda
2026-09-01 23:07 ` Kees Cook
2026-09-01 23:07 ` Mark Brown
2026-09-01 23:06 ` Kees Cook
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox