kernel::fs::file::LocalFile
should be marked as repr(transparent)
#1165
Labels
good first issue
Good for newcomers
• lib
Related to the `rust/` library.
medium
Expected to be an issue of medium difficulty to resolve.
Unlike
File
which usesrepr(transparent)
,LocalFile
uses the implicitrepr(Rust)
representation which has an unspecified layout. This can break unsafe code that assumes that it has the same layout asbindings::file
.For example, the
LocalFile::from_raw_file
function casts*const bindings::file
to*const LocalFile
:linux/rust/kernel/fs/file.rs
Lines 274 to 280 in f264495
Note that the safety comment here should be talking about
LocalFile
instead ofFile
(probably a copy-paste error). Some other comments also refer to the wrong type (lines 227 and 238).In practice, the default representation most likely uses the same layout as with
repr(transparent)
, but it's best to not rely on that since it's unspecified.The text was updated successfully, but these errors were encountered: