Re: [PATCH v4 6/6] rust: use strict provenance APIs
From: Tamir Duberstein
Date: Sun Mar 16 2025 - 08:55:08 EST
On Sun, Mar 16, 2025 at 1:01 AM Boqun Feng <boqun.feng@xxxxxxxxx> wrote:
>
> On Sat, Mar 15, 2025 at 08:17:30AM -0400, Tamir Duberstein wrote:
> [...]
> > diff --git a/rust/kernel/of.rs b/rust/kernel/of.rs
> > index 40d1bd13682c..f9459694cbdc 100644
> > --- a/rust/kernel/of.rs
> > +++ b/rust/kernel/of.rs
> > @@ -22,7 +22,7 @@ unsafe impl RawDeviceId for DeviceId {
> > const DRIVER_DATA_OFFSET: usize = core::mem::offset_of!(bindings::of_device_id, data);
> >
> > fn index(&self) -> usize {
> > - self.0.data as usize
> > + crate::expose_provenance(self.0.data)
>
> Even though of_device_id::data was defined as `void *`, but in Rust we
> use it to store index, see kernel::device_id::{IdTable::info(),
> IdArray::new()}. Hence we should use self.0.data.addr() here.
Good point, thanks.