LiveActive security incident?Get immediate response
CVE Record

CVE-2026-31584: media: mediatek: vcodec: fix use-after-free in encoder release path

In the Linux kernel, the following vulnerability has been resolved: media: mediatek: vcodec: fix use-after-free in encoder release path The fops_vcodec_release() function frees the context structure (ctx) without first cancelling any pending or running work in ctx->encode_work. This creates a race window where the workqueue handler (mtk_venc_worker) may still be accessing the context memory after it has been freed. Race condition: CPU 0 (release path) CPU 1 (workqueue) --------------------- ------------------ fops_vcodec_release() v4l2_m2m_ctx_release() v4l2_m2m_cancel_job() // waits for m2m job "done" mtk_venc_worker() v4l2_m2m_job_finish() // m2m job "done" // BUT worker still running! // post-job_finish access: other ctx dereferences // UAF if ctx already freed // returns (job "done") kfree(ctx) // ctx freed Root cause: The v4l2_m2m_ctx_release() only waits for the m2m job lifecycle (via TRANS_RUNNING flag), not the workqueue lifecycle. After v4l2_m2m_job_finish() is called, the m2m framework considers the job complete and v4l2_m2m_ctx_release() returns, but the worker function continues executing and may still access ctx. The work is queued during encode operations via: queue_work(ctx->dev->encode_workqueue, &ctx->encode_work) The worker function accesses ctx->m2m_ctx, ctx->dev, and other ctx fields even after calling v4l2_m2m_job_finish(). This vulnerability was confirmed with KASAN by running an instrumented test module that widens the post-job_finish race window. KASAN detected: BUG: KASAN: slab-use-after-free in mtk_venc_worker+0x159/0x180 Read of size 4 at addr ffff88800326e000 by task kworker/u8:0/12 Workqueue: mtk_vcodec_enc_wq mtk_venc_worker Allocated by task 47: __kasan_kmalloc+0x7f/0x90 fops_vcodec_open+0x85/0x1a0 Freed by task 47: __kasan_slab_free+0x43/0x70 kfree+0xee/0x3a0 fops_vcodec_release+0xb7/0x190 Fix this by calling cancel_work_sync(&ctx->encode_work) before kfree(ctx). This ensures the workqueue handler is both cancelled (if pending) and synchronized (waits for any running handler to complete) before the context is freed. Placement rationale: The fix is placed after v4l2_ctrl_handler_free() and before list_del_init(&ctx->list). At this point, all m2m operations are done (v4l2_m2m_ctx_release() has returned), and we need to ensure the workqueue is synchronized before removing ctx from the list and freeing it. Note: The open error path does NOT need cancel_work_sync() because INIT_WORK() only initializes the work structure - it does not schedule it. Work is only scheduled later during device_run() operations.

HighCVSS 7.8Not KEV-listedUpdated
Glexia's TakeAutomated analysishigh

Security readout for executives and security teams

Plain-English summary

A race in the Linux MediaTek video encoder driver can let background work access memory after it has been freed. A local, low-privileged user able to exercise the encoder could potentially crash the system or compromise kernel confidentiality and integrity. Exposure depends on affected kernel code and MediaTek encoder availability.

Executive priority

Prioritize affected multi-user systems, devices running untrusted local applications, and workloads exposing hardware video encoding. Patch through normal urgent kernel maintenance after confirming applicability. Systems without the MediaTek encoder path are lower priority, but require documented verification rather than version-only assumptions.

Technical view

The encoder release path frees its context while encode_work may still be running. Because v4l2_m2m_ctx_release() waits for job completion but not workqueue completion, mtk_venc_worker can dereference the freed context. KASAN confirmed a slab use-after-free. The fix synchronously cancels encode_work before removing and freeing the context.

Likely exposure

Likely exposure is limited to Linux systems using affected kernel versions with the MediaTek vcodec encoder driver present and accessible locally. The supplied record identifies affected releases including 6.6, 6.6.136, 6.12.83, 6.18.24, 6.19.14, 7.0.1, and 7.1; confirm vendor backports before deciding status.

Exploitation context

The supplied CVSS 3.1 score is 7.8 with local access, low complexity, low privileges, and no user interaction. The issue was reproduced using KASAN with an instrumented test module. The record is not in KEV, and the supplied sources provide no evidence of active exploitation or a public weaponized exploit.

Researcher notes

The key synchronization gap occurs after v4l2_m2m_job_finish(): the framework considers the job complete while the worker continues dereferencing ctx. The prescribed placement waits for pending or running encode_work after m2m teardown and before list removal and kfree. The open error path is reportedly unaffected because INIT_WORK does not schedule work.

Mitigation direction

  • Update to a vendor-supported kernel containing the applicable referenced stable fix.
  • Confirm the vendor kernel includes cancel_work_sync() for ctx->encode_work before context removal and freeing.
  • Where updates are delayed, restrict untrusted local access to affected MediaTek video-encoding interfaces.
  • Consult distribution or device-vendor guidance for exact fixed package and reboot requirements.

Validation and detection

  • Inventory kernel versions and systems containing the MediaTek vcodec encoder driver.
  • Check vendor advisories or source history for one of the referenced fix commits or an equivalent backport.
  • Confirm the running kernel changed after updating; an installed package alone may not remove exposure.
  • Use controlled KASAN regression testing to confirm encoder release no longer triggers the use-after-free.
  • Review kernel logs for MediaTek encoder crashes or memory-safety reports, without treating absence as proof.
Prepared
Confidence
high
Sources
8

Generated from the cited source records. This long-tail analysis has not been individually reviewed by a named human.

Potential ATT&CK relevance

Conservative CVE-to-ATT&CK context

These mappings and lookup hints may be relevant to the vulnerability behavior, CWE, affected product, or exposure path. Glexia-inferred context is not an official MITRE, ATT&CK, CWE, or CVE Program mapping.

ATT&CK lookup starting points

Use these exact CWE pages and searches to review the Glexia ATT&CK library from this CVE's weakness and description context.

cve · low confidence lookup

CVE-2026-31584 mapping review

Open the CVE-to-ATT&CK bridge for reviewed, inferred, or future official mappings tied to this CVE.

Open ATT&CK lookup
Vulnerability profileCVE Program record
Severity
High
CVSS
7.8 (3.1)
Known Exploited
No
Published

Vector: CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

Official CVE source material

CNA and ADP enrichment extracted from CVE v5

These fields come from the CVE record and ADP containers, not from Glexia's Take. They preserve time-varying source decisions such as CISA SSVC, KEV status, CVSS metrics, and provider references.

1CVSS vectors
3Timeline events
0ADP providers
7Source links

CVSS vector scores

1 official score

We collect every scored CVSS vector available in the official CNA and ADP containers. When more than one version is present, the table keeps the source vectors side by side instead of collapsing them into the highest score.

ScoreVersionSeverityVectorExploitImpactSource
7.8CVSS 3.1HighCVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H1.85.9Linux

Vulnerability scoring details

Base CVSS 3.1 score

7.8High
CVSS 3.1 vector shape for CVE-2026-31584Attack VectorAttack ComplexityPrivileges RequiredUser InteractionScopeConfidentiality ImpactIntegrity ImpactAvailability Impact

Vector: CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

Attack Vector
NetworkAdjacentLocalPhysical
Attack Complexity
LowHigh
Privileges Required
NoneLowHigh
User Interaction
NoneRequired
Scope
ChangedUnchanged
Confidentiality Impact
HighLowNone
Integrity Impact
HighLowNone
Availability Impact
HighLowNone

Vulnerability timeline

Timeline events are normalized from CVE metadata, CNA source timelines, ADP timelines, and KEV metadata when present.

  1. CVE reservedCVE Program

    The CVE ID was reserved by the assigning CNA.

  2. CVE publishedCVE Program

    The CVE record was published.

  3. CVE updatedCVE Program

    The CVE record metadata indicates this as the latest update time.

Affected products

Products and packages named in the record

VendorProductVersion / packageStatus
LinuxLinux0934d37596151edce115c6d0843a9ad7d5e5d232, 0934d37596151edce115c6d0843a9ad7d5e5d232, 0934d37596151edce115c6d0843a9ad7d5e5d232, 0934d37596151edce115c6d0843a9ad7d5e5d232, 0934d37596151edce115c6d0843a9ad7d5e5d232, 0934d37596151edce115c6d0843a9ad7d5e5d232unaffected
LinuxLinux6.6, 0, 6.6.136, 6.12.83, 6.18.24, 6.19.14, 7.0.1, 7.1affected
Weakness

CWE details

No CWE listed

CWE links open Glexia weakness intelligence pages with official CWE context, developer remediation guidance, and related CVE mappings.