If we do not enter dummy_chan_trigger() before detaching, we'll get a
use-after-free since the callout(9) callback might be called after
having been detached.
Sponsored by: The FreeBSD Foundation
MFC after: 2 days
Differential D46715
snd_dummy: Drain callout during detach christos on Sep 20 2024, 2:57 PM. Authored by Tags None Referenced Files
Subscribers
Details If we do not enter dummy_chan_trigger() before detaching, we'll get a Sponsored by: The FreeBSD Foundation
Diff Detail
Event TimelineComment Actions callout_drain() will wait for the callout to finish, instead of stopping it immediately. Is there an advantage to using this? Comment Actions Yes, it ensures that the callout won't be running while dummy_detach() runs concurrently. This patch makes the use-after-free harder to hit, but doesn't fix it completely. Comment Actions If the callout stops before pcm_unregister() is called, read/write operations will have stopped already in the case of snd_dummy, so we shouldn't hit any use-after-free. That being said, I guess it could be made even more robust by check whether &sc->chans[i] is NULL in the dummy_chan_io() loop, even though the channels pointed to by sc->chans are freed in pcm_unregister(). |