linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rust: mm: Mark VmaNew as transparent
@ 2025-08-12 13:26 Baptiste Lepers
  2025-08-12 13:36 ` Alice Ryhl
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Baptiste Lepers @ 2025-08-12 13:26 UTC (permalink / raw)
  Cc: Baptiste Lepers, Alice Ryhl, Lorenzo Stoakes, Liam R. Howlett,
	Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Trevor Gross, Danilo Krummrich, Jann Horn, Andrew Morton,
	linux-mm, rust-for-linux, linux-kernel

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.

Fixes: dcb81aeab406e ("mm: rust: add VmaNew for f_ops->mmap()")
Signed-off-by: Baptiste Lepers <baptiste.lepers@gmail.com>
---
 rust/kernel/mm/virt.rs | 1 +
 1 file changed, 1 insertion(+)

diff --git a/rust/kernel/mm/virt.rs b/rust/kernel/mm/virt.rs
index 6086ca981b06..a1bfa4e19293 100644
--- a/rust/kernel/mm/virt.rs
+++ 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,
 }
-- 
2.43.0



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

end of thread, other threads:[~2025-08-21 10:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-08-12 13:26 [PATCH] rust: mm: Mark VmaNew as transparent Baptiste Lepers
2025-08-12 13:36 ` Alice Ryhl
2025-08-12 14:11 ` Greg KH
2025-08-20 23:29 ` Andrew Morton
2025-08-21  9:45   ` Alice Ryhl
2025-08-21 10:31     ` Miguel Ojeda

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