On Tue, 01 Aug 2023 19:18:41 +0200, cujomalainey@xxxxxxxxxxxx wrote: > > From: Curtis Malainey <cujomalainey@xxxxxxxxxxxx> > > The current implementation of how devices are released is valid for > production use cases (root control of memory is handled by card_dev, all > other devices are no-ops). > > This model does not work though in a kernel hacking environment where > KASAN and delayed release on kobj is enabled. If the card_dev device is > released before any of the child objects a use-after-free bug is caught > by KASAN as the delayed release still has a reference to the devices > that were freed by the card_dev release. Also both snd_card and snd_pcm > both own two devices internally, so even if they released independently, > the shared struct would result in another use after free. > > Solution is to move the child devices into their own memory so they can > be handled independently and released on their own schedule. > > Signed-off-by: Curtis Malainey <cujomalainey@xxxxxxxxxxxx> > Cc: Doug Anderson <dianders@xxxxxxxxxxxx> Thanks, it's an interesting bug. I'm not much against the proposed solution, but still this has to be carefully evaluated. So, could you give more details about the bug itself? It's related with CONFIG_DEBUG_KOBJECT_RELEASE, right? In which condition it's triggered and how the UAF looks like? Takashi