On Sun, Jan 16, 2022 at 06:17:16AM +0000, Visa Hankala wrote:
> On Sun, Jan 16, 2022 at 02:41:46PM +1000, David Gwynne wrote:
> > if you're in bpfclose or tun/tap close, you're the last one out. this
> > means that there shouldn't be anything else in poll/select/kevent/etc
> > because you're the last one out.
> > 
> > from what i can tell, tun and bpf are the only drivers that do this, and
> > i dont think they need to.
> 
> The last one out holds when the device closing is triggered by the
> releasing of the last file reference. However, bpf/tun/tap close can
> also be called when the device is detached through VOP_REVOKE(). In
> that case any associated file descriptors remain open.

iirc, revoke can call fooclose() before it swaps the vnode ops out for
the dead ones. so yes, the fd is open but it's state becomes divorced
from the special device it was originally associated with.

> I think poll/select/kevent should wake up if the device is detached.
> kevent(2) and kqueue-based select(2) get notified as a result of
> klist_invalidate().
> 
> There is also the SIGIO case, but only bpf close raises the signal.
> 
> To be on the safer side, I would wait until poll(2) uses kqueue backed.

grumble grumble. yes.

or the detach code that calls revoke and klist_invalidate should also do
selwakeup...

Reply via email to