On Tue, Feb 03, 2026 at 10:10:57AM +0100, Maxime Ripard wrote: > On Fri, Jan 30, 2026 at 11:10:49AM +0200, Laurent Pinchart wrote: > > On Thu, Jan 29, 2026 at 11:29:03PM +0100, Danilo Krummrich wrote: > > > (Cc: Maxime, Thomas, Maarten) > > > > > > On Thu Jan 29, 2026 at 2:08 AM CET, Laurent Pinchart wrote: > > > > That's what I've been advocating for. The best way to ensure that driver > > > > code will not accessed data freed at .remove() time is to prevent the > > > > code to run at all. > > > > > > With this we are in full agreement, I think that'd be best too. But, I > > > also > > > think that sometimes this isn't possible. For instance, DRM has such a > > > case with > > > atomic mode setting. > > > > I don't see why it would be impossible there. > > I'm not quite sure what you have in mind there, but DRM always allowed > the DRM driver to stick around longer than its device to accomodate the > fact that userspace might still have an open fd to it. > > If userspace has an open fd, it can still call ioctl so preventing to > run any code is going to be difficult.
Preventing new ioctls (and other fops) from being called isn't difficult, they can be blocked at the entry point, outside of the driver. In-progress ioctls running in other threads can also be forced to complete before .remove() frees all memory. I think this is the right thing to do. The only fop that we can't completely prevent from running is .release(), as we can't wait until userspace closes all file handles and unmaps all memory before .remove() completes. There are solutions for that. -- Regards, Laurent Pinchart
