On Wed, 2026-12-02 at 17:12 +0000, Gary Guo wrote:

[…]

> > +        // If a DriverFence signals without doing a synchronize_rcu(), and 
> > a
> > +        // fctx drops immediately afterwards, then backend_ops still 
> > accessing
> > +        // the fctx might run into UAF if we don't wait for them here.
> > +        synchronize_rcu();
> 
> This condition is only true for !needs_drop?
> 
> I think this should be
> 
>     if !needs_drop::<...>() {
>         synchronize_rcu();
>     }

No, because fence callbacks also access the driver_name and
timeline_name strings in the fctx and only are guaranteed to have
stopped that after the last fence was signaled :)

Besides fctx drop is not a hot path, they drop relatively rarely.

> > +        // SAFETY: Valid because `self` is valid. RCU above ensures that 
> > all
> > +        // accessors are gone.
> > +        unsafe { drop_in_place(&raw mut self.data) };
> 
> Sashiko's finding is valid here.


So if I do drop_in_place(NonNull) it does not invoke NonNull's drop in
place?

https://rust.docs.kernel.org/next/core/ptr/struct.NonNull.html#method.drop_in_place


So I gotta do `NonNull::drop_in_place(self.data)`.

That's not super intuitive. If I do `drop(foo)`, then it will call
foo's drop implementation.

I understand why a drop(non_null) must not behave like that, but from a
drop_in_place(non_null) I would expect it to call the deconstructor.


P.

Reply via email to