[PATCH] rust: drm: Drop the use of Opaque for ioctl arguments
Alice Ryhl
aliceryhl at google.com
Thu Jun 19 12:34:24 UTC 2025
On Thu, Jun 19, 2025 at 1:01 PM Benno Lossin <lossin at kernel.org> wrote:
>
> On Thu Jun 19, 2025 at 12:55 PM CEST, Danilo Krummrich wrote:
> > On Thu, Jun 19, 2025 at 12:21:02PM +0200, Beata Michalska wrote:
> >> diff --git a/rust/kernel/drm/ioctl.rs b/rust/kernel/drm/ioctl.rs
> >> index 445639404fb7..12b296131672 100644
> >> --- a/rust/kernel/drm/ioctl.rs
> >> +++ b/rust/kernel/drm/ioctl.rs
> >> @@ -139,7 +139,7 @@ pub mod internal {
> >> // asserted above matches the size of this type, and all bit patterns of
> >> // UAPI structs must be valid.
> >> let data = unsafe {
> >> - &*(raw_data as *const $crate::types::Opaque<$crate::uapi::$struct>)
> >> + &mut *(raw_data as *mut $crate::uapi::$struct)
> >
> > I think we have to document the guarantees we rely on to create this mutable
> > reference.
>
> If the C side is using pointers to read/write the value concurrently,
> this is wrong, it needs to be wrapped in Opaque.
There's no concurrent reads or writes happening here. I think the
Opaque was added to deal with transmutes to/from byte arrays.
Alice
More information about the dri-devel
mailing list