CVE-2026-99511: media: cx23885: Fix use-after-free in cx23885_finidev due to race condition
In the Linux kernel, the following vulnerability has been resolved:
media: cx23885: Fix use-after-free in cx23885finidev due to race condition
In cx23885v4l2devnotifyinit, &dev->cx25840work is bound with cx23885avworkhandler, and &dev->irrxwork and &dev->irtxwork are bound with cx23885irrxworkhandler and cx23885irtxworkhandler. cx23885irq can schedule these works on systemwq when an AVCORE interrupt is received, and the IR subdevice can also schedule the IR works from its interrupt service routine via the v4l2device notify callback.
If we remove the device, cx23885finidev makes cleanup and the memory allocated for dev is released by kfree(dev), while the works mentioned above may still be pending or running. The sequence of operations that may lead to a UAF bug is as follows:
CPU0 CPU1
| cx23885irq | schedulework(&dev->cx25840work) cx23885finidev | cx23885inputfini(dev) | cx23885irfini(dev) | cx23885shutdown(dev) | freeirq(pcidev->irq, dev) | pcidisabledevice(pcidev) | cx23885devunregister(dev) | v4l2deviceunregister(v4l2dev) | kfree(dev) | // dev is freed | | cx23885avworkhandler | // use dev (use-after-free)
Fix it by canceling the works after the IRQ handler that can schedule them has been stopped, and before proceeding with the remaining cleanup in cx23885finidev.
Note that the flushwork() calls in cx23885inputirstop() do not close this race: they only wait for works that are already queued or running at that moment, they do not prevent the IRQ handler, which is still registered at that point, from scheduling the works again afterwards, and they are skipped entirely when dev->sdir is NULL. The cancelworksync() calls are therefore placed after freeirq(), the only point at which no new work can be scheduled.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.12.117 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.18.61 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 7.3.2 - Compensating control
After free_irq(), call cancel_work_sync() for the IRQ-schedulable works (including cx25840_work, ir_rx_work, and ir_tx_work) before freeing dev; skip the IR-work cancellation when dev->sd_ir is NULL.