CVE-2026-99468: media: imx-jpeg: cancel timeout worker when streaming stops
In the Linux kernel, the following vulnerability has been resolved:
media: imx-jpeg: cancel timeout worker when streaming stops
Each per-fd context ctx owns a delayedwork (ctx->tasktimer, callback mxcjpegdeviceruntimeout) armed via scheduledelayedwork() at the end of mxcjpegdevicerun() to recover a stalled encode/decode job. The only existing cancellation is canceldelayedwork() in the frame-done IRQ handler, which de-queues a pending work item but does not wait for a callback that has already started, and it only runs when a frame completes.
When the fd is closed while a job is in flight (the frame-done IRQ has not fired yet), nothing syncs the worker before mxcjpegrelease() frees ctx with kfree() after v4l2m2mctxrelease(). A queued or executing mxcjpegdeviceruntimeout() can then recover ctx through containerof(&ctx->tasktimer) and dereference it (ctx->mxcjpeg, slotdata, devwarn) after ctx has been freed.
Cancel the worker from mxcjpegstopstreaming(). The cancel cannot live in mxcjpegrelease(): mxcjpegdevicerun() arms the timer while holding only hwlock, not the mxcjpeg->lock mutex that release holds, so a cancel in release could still race a concurrent mxcjpegdevicerun() that re-arms the timer afterwards. mxcjpegstopstreaming() instead runs inside v4l2m2mctxrelease() -> vb2queuerelease(), i.e. after v4l2m2mcanceljob() has set TRANSABORT and waited for any in-flight job to finish (so v4l2m2mtryqueue() will not queue and v4l2m2mtryrun() will not run any further job for this context, which prevents mxcjpegdevicerun() from re-arming the timer) and before the m2m context is freed. canceldelayedworksync() removes a pending work item and waits for a running callback, so the worker can no longer race with the subsequent kfree(). The cancel is placed before the buffer-release loop so a concurrently running timeout callback cannot race with it over the same buffers. If the frame-done IRQ canceled a still-pending timer, this cancel is a no-op; if the timeout callback has already started, it waits for the callback to finish. The same mxcjpegstopstreaming() call is also reached from VIDIOCSTREAMOFF, which drains the worker early, although STREAMOFF itself does not free ctx -- the use-after-free arises only when the fd is later closed.
This bug was found by static analysis.
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.2 - 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
In the imx-jpeg driver, call cancel_delayed_work_sync() from mxc_jpeg_stop_streaming() before the buffer-release loop so the timeout worker is canceled and any running callback finishes before buffers are released.