Linux Security Modules development
 help / color / mirror / Atom feed
* [PATCH v3] hardening: Default randstruct off with rust for better allmodconfig support
@ 2026-07-02 17:37 Mark Brown
  2026-07-13 12:45 ` Mark Brown
  0 siblings, 1 reply; 5+ messages in thread
From: Mark Brown @ 2026-07-02 17:37 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 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>


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v3] hardening: Default randstruct off with rust for better allmodconfig support
  2026-07-02 17:37 [PATCH v3] hardening: Default randstruct off with rust for better allmodconfig support Mark Brown
@ 2026-07-13 12:45 ` Mark Brown
  2026-07-13 13:54   ` Gary Guo
  0 siblings, 1 reply; 5+ messages in thread
From: Mark Brown @ 2026-07-13 12:45 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

[-- Attachment #1: Type: text/plain, Size: 651 bytes --]

On Thu, Jul 02, 2026 at 06:37:08PM +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.

Any news on this?  I'm flying blind doing -next merges of rust code with
build coverage gone, and I suspect a bunch of other people think they
have build coverage in their tests but it's silently vanished (I know at
least one person ran into that already).

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v3] hardening: Default randstruct off with rust for better allmodconfig support
  2026-07-13 12:45 ` Mark Brown
@ 2026-07-13 13:54   ` Gary Guo
  2026-07-13 13:58     ` Miguel Ojeda
  0 siblings, 1 reply; 5+ messages in thread
From: Gary Guo @ 2026-07-13 13:54 UTC (permalink / raw)
  To: Mark Brown, 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

On Mon Jul 13, 2026 at 1:45 PM BST, Mark Brown wrote:
> On Thu, Jul 02, 2026 at 06:37:08PM +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.
>
> Any news on this?  I'm flying blind doing -next merges of rust code with
> build coverage gone, and I suspect a bunch of other people think they
> have build coverage in their tests but it's silently vanished (I know at
> least one person ran into that already).

I thought Miguel wants to add support to properly support RANDSTRUCT with Clang?

Best,
Gary

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v3] hardening: Default randstruct off with rust for better allmodconfig support
  2026-07-13 13:54   ` Gary Guo
@ 2026-07-13 13:58     ` Miguel Ojeda
  2026-07-13 14:02       ` Mark Brown
  0 siblings, 1 reply; 5+ messages in thread
From: Miguel Ojeda @ 2026-07-13 13:58 UTC (permalink / raw)
  To: Gary Guo
  Cc: Mark Brown, Kees Cook, Gustavo A. R. Silva, Paul Moore,
	James Morris, Serge E. Hallyn, Miguel Ojeda, Boqun Feng,
	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 Mon, Jul 13, 2026 at 3:55 PM Gary Guo <gary@garyguo.net> wrote:
>
> I thought Miguel wants to add support to properly support RANDSTRUCT with Clang?

I am happy either way, i.e. whatever the hardening folks prefer, but
regardless of what we do, I think recovering the linux-next coverage
is a high priority at the moment.

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v3] hardening: Default randstruct off with rust for better allmodconfig support
  2026-07-13 13:58     ` Miguel Ojeda
@ 2026-07-13 14:02       ` Mark Brown
  0 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2026-07-13 14:02 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Gary Guo, Kees Cook, Gustavo A. R. Silva, Paul Moore,
	James Morris, Serge E. Hallyn, Miguel Ojeda, Boqun Feng,
	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: 734 bytes --]

On Mon, Jul 13, 2026 at 03:58:11PM +0200, Miguel Ojeda wrote:
> On Mon, Jul 13, 2026 at 3:55 PM Gary Guo <gary@garyguo.net> wrote:

> > I thought Miguel wants to add support to properly support RANDSTRUCT with Clang?

It would be great to have randstruct support for clang and Rust but we
do not currently have that support.

> I am happy either way, i.e. whatever the hardening folks prefer, but
> regardless of what we do, I think recovering the linux-next coverage
> is a high priority at the moment.

Yeah, when randstruct support is added we can remove all the constraints
around it and clang/Rust - this patch is about the making the current
situation work more usefully, it's not intended to be a final state.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-07-13 14:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-02 17:37 [PATCH v3] hardening: Default randstruct off with rust for better allmodconfig support Mark Brown
2026-07-13 12:45 ` Mark Brown
2026-07-13 13:54   ` Gary Guo
2026-07-13 13:58     ` Miguel Ojeda
2026-07-13 14:02       ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox