media: mtk-jpeg: Fix use after free bug due to error path handling in mtk_jpeg_dec_device_run
Description
A use-after-free in the mtk-jpeg decoder driver due to a race between error handling and timeout worker cleanup.
AI Insight
LLM-synthesized narrative grounded in this CVE's description and references.
A use-after-free in the mtk-jpeg decoder driver due to a race between error handling and timeout worker cleanup.
Vulnerability
In the Linux kernel's MediaTek JPEG decoder driver (mtk-jpeg), a use-after-free vulnerability exists in mtk_jpeg_dec_device_run [1]. The function binds jpeg->job_timeout_work to mtk_jpeg_job_timeout_work during probe. In the device run handler, if mtk_jpeg_set_dec_dst fails, the error path starts the timeout worker and then marks the job as finished via v4l2_m2m_job_finish. This creates a race condition where the timeout worker may access freed memory after module removal or file descriptor close. Versions affected are those prior to the fix commit.
Exploitation
An attacker can trigger this condition by forcing an error in mtk_jpeg_set_dec_dst (e.g., by exhausting resources) while concurrently removing the module or closing the file descriptor. No special privileges are required beyond access to the video device. The race window exists between the timeout worker execution and the cleanup path.
Impact
Successful exploitation leads to a use-after-free condition, which can result in memory corruption or privilege escalation. In the worst case, this could allow an attacker to execute arbitrary code in kernel context, leading to full system compromise.
Mitigation
The fix, included in Linux kernel commits, ensures the timeout worker is only started if the decoder worker starts successfully. Users should update to a kernel version containing the fix [1]. No workaround is available; vendors have released patches as part of their kernel updates.
AI Insight generated on May 25, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.
Affected products
6- osv-coords4 versionspkg:deb/ubuntu/linux-aws@6.5.0-1021.21?arch=source&distro=manticpkg:deb/ubuntu/linux-laptop@6.5.0-1017.20?arch=source&distro=manticpkg:deb/ubuntu/linux-oem-6.5pkg:deb/ubuntu/linux-oracle@6.5.0-1024.24?arch=source&distro=mantic
< 6.5.0-1021.21+ 3 more
- (no CPE)range: < 6.5.0-1021.21
- (no CPE)range: < 6.5.0-1017.20
- (no CPE)range: < 6.5.0-1022.23
- (no CPE)range: < 6.5.0-1024.24
Patches
0No patches discovered yet.
Vulnerability mechanics
No source-code context for this CVE — mechanics is only generated when we can read the actual fix diff. Without that, the four sections (root cause, attack vector, affected code, fix) would be speculation rather than analysis.
References
6- git.kernel.org/stable/c/1b1036c60a37a30caf6759a90fe5ecd06ec35590mitre
- git.kernel.org/stable/c/206c857dd17d4d026de85866f1b5f0969f2a109emitre
- git.kernel.org/stable/c/43872f44eee6c6781fea1348b38885d8e78face9mitre
- git.kernel.org/stable/c/6e2f37022f0fc0893da4d85a0500c9d547fffd4cmitre
- git.kernel.org/stable/c/8254d54d00eb6cdb8367399c7f912eb8d354ecd7mitre
- git.kernel.org/stable/c/9fec4db7fff54d9b0306a332bab31eac47eeb5f6mitre
News mentions
0No linked articles in our index yet.