Re: [PATCH] rust: mm: Mark VmaNew as transparent

From: Andrew Morton
Date: Wed Aug 20 2025 - 19:29:39 EST


On Tue, 12 Aug 2025 15:26:56 +0200 Baptiste Lepers <baptiste.lepers@xxxxxxxxx> wrote:

> Unsafe code in VmaNew's methods assumes that the type has the same
> layout as the inner `bindings::vm_area_struct`. This is not guaranteed by
> the default struct representation in Rust, but requires specifying the
> `transparent` representation.
>
> ...
>
> +++ b/rust/kernel/mm/virt.rs
> @@ -209,6 +209,7 @@ pub fn vm_insert_page(&self, address: usize, page: &Page) -> Result {
> ///
> /// For the duration of 'a, the referenced vma must be undergoing initialization in an
> /// `f_ops->mmap()` hook.
> +#[repr(transparent)]
> pub struct VmaNew {
> vma: VmaRef,
> }

Alice suggests that I add a cc:stable to this. But I see nothing in
the changelog which explains why we're proposing a backport.

So please send us a description of the userspace-visible runtime
impact of this flaw and I'll paste it into the changelog, thanks.