Skip to content

Commit 5cc5e03

Browse files
BLepersakpm00
authored andcommitted
rust: mm: mark VmaNew as transparent
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. Link: https://lkml.kernel.org/r/[email protected] Fixes: dcb81ae ("mm: rust: add VmaNew for f_ops->mmap()") Signed-off-by: Baptiste Lepers <[email protected]> Reviewed-by: Alice Ryhl <[email protected]> Cc: Alex Gaynor <[email protected]> Cc: Andreas Hindborg <[email protected]> Cc: Björn Roy Baron <[email protected]> Cc: Boqun Feng <[email protected]> Cc: Danilo Krummrich <[email protected]> Cc: Gary Guo <[email protected]> Cc: Jann Horn <[email protected]> Cc: Liam Howlett <[email protected]> Cc: Lorenzo Stoakes <[email protected]> Cc: Miguel Ojeda <[email protected]> Cc: Trevor Gross <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent ee4d098 commit 5cc5e03

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

rust/kernel/mm/virt.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ impl VmaMixedMap {
209209
///
210210
/// For the duration of 'a, the referenced vma must be undergoing initialization in an
211211
/// `f_ops->mmap()` hook.
212+
#[repr(transparent)]
212213
pub struct VmaNew {
213214
vma: VmaRef,
214215
}

0 commit comments

Comments
 (0)