Skip to content

Do not allow subverting kernel! soundness by using #[doc(hidden)] items - #363

Merged
Shnatsel merged 3 commits into
linebender:mainfrom
Shnatsel:more-sound-kernel
Sep 1, 2026
Merged

Do not allow subverting kernel! soundness by using #[doc(hidden)] items#363
Shnatsel merged 3 commits into
linebender:mainfrom
Shnatsel:more-sound-kernel

Conversation

@Shnatsel

Copy link
Copy Markdown
Contributor

The threat model for Rust is that the code written by the programmer is non-adversarial. So having some #[doc(hidden)] items is fine.

However, LLMs still flag this in an audit, and it's easier to tighten things up once and for all than to explain to users that this is actually fine every time.

@DJMcNab

DJMcNab commented Aug 31, 2026

Copy link
Copy Markdown
Member

Could you expand on what hole this is closing? I'm definitely hesitant to have a soundness break unless it's unavoidable, so I'd rather have a fix.

I presume that the type being doc(hidden) doesn't have any impact there - I'm not aware of any semantics impact of that attribute.

@Shnatsel

Copy link
Copy Markdown
Contributor Author

Prior to this PR, __fearless_simd_kernel_impl! accepted both the level token and the corresponding target feature string as arguments and trusts them. So one could theoretically use this private-ish, low-level and doc-hidden API (which can't be fully private due to use in macros which instantiate outside this crate) to construct a function that accepts e.g. an SSE2 token but emits an AVX-512 feature string.

Rust is not a sandbox to defend against adversarial code, unlike e.g. JavaScript running in the browser, so if someone went through this much trouble to get a soundness issue, they probably deserve it. But this PR fixes this loophole regardless.

@DJMcNab DJMcNab left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@Shnatsel
Shnatsel added this pull request to the merge queue Sep 1, 2026
Merged via the queue into linebender:main with commit 3d5a567 Sep 1, 2026
22 checks passed
@Shnatsel
Shnatsel deleted the more-sound-kernel branch September 1, 2026 00:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants