Re: [PATCH v5 01/19] rust: drm: ioctl: fix unbounded lifetimes in ioctl handler arguments
"Alexandre Courbot" <[email protected]>
| Newsgroups | dev.linux.lists.nova-gpu,dev.linux.lists.driver-core,org.freedesktop.lists.dri-devel,org.kernel.vger.linux-kernel,org.kernel.vger.rust-for-linux,org.kernel.vger.stable |
|---|---|
| Message-ID | <[email protected]> |
On Sun Jun 28, 2026 at 11:53 PM JST, Danilo Krummrich wrote: > References to dev, data, and file in the declare_drm_ioctls! macro are > created via unsafe pointer dereferences, producing unbounded lifetimes. > If an ioctl handler explicitly annotates its parameters with 'static, > the compiler accepts this, allowing the handler to stash references that > outlive the ioctl call. > > Fix this by adding a higher-ranked function pointer coercion that > enforces the handler accepts universally quantified lifetimes: > > let _: for<'a> fn(&'a _, &'a mut _, &'a _) -> _ = $func; > > Since the handler must be coercible to a function pointer accepting any > lifetime 'a, it can no longer demand 'static on any parameter. > > Cc: [email protected] > Fixes: 9a69570682b1 ("rust: drm: ioctl: Add DRM ioctl abstraction") > Reported-by: [email protected] > Closes: https://lore.kernel.org/all/[email protected]/ > Suggested-by: Gary Guo <[email protected]> > Signed-off-by: Danilo Krummrich <[email protected]> Reviewed-by: Alexandre Courbot <[email protected]>