# CVE-2025-40096: drm/sched: Fix potential double free in drm_sched_job_add_resv_dependencies

> A double free vulnerability in the Linux kernel's DRM scheduler allows attackers to cause denial of service or potentially execute arbitrary code.

- **Severity:** High 7.8 (`CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Any signed-in user
- **Attackable:** Local or same network only
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 30 Oct 2025
- **Updated:** 5 Aug 2026
- **Also known as:** AZL-69409, BELL-CVE-2025-40096, DEBIAN-CVE-2025-40096, GHSA-xpm8-g6rj-74pw, ROOT-OS-DEBIAN-12-CVE-2025-40096, ROOT-OS-DEBIAN-13-CVE-2025-40096, ROOT-OS-UBUNTU-2404-CVE-2025-40096, UBUNTU-CVE-2025-40096

## What is CVE-2025-40096?

CVE-2025-40096 is a high-severity use after free vulnerability in Linux, published on 30 Oct 2025. It can only be exploited from the same machine or local network, with no action from the victim.

### Official description

In the Linux kernel, the following vulnerability has been resolved:

drm/sched: Fix potential double free in drm_sched_job_add_resv_dependencies

When adding dependencies with drm_sched_job_add_dependency(), that
function consumes the fence reference both on success and failure, so in
the latter case the dma_fence_put() on the error path (xarray failed to
expand) is a double free.

Interestingly this bug appears to have been present ever since
commit ebd5f74255b9 ("drm/sched: Add dependency tracking"), since the code
back then looked like this:

drm_sched_job_add_implicit_dependencies():
...
       for (i = 0; i < fence_count; i++) {
               ret = drm_sched_job_add_dependency(job, fences[i]);
               if (ret)
                       break;
       }

       for (; i < fence_count; i++)
               dma_fence_put(fences[i]);

Which means for the failing 'i' the dma_fence_put was already a double
free. Possibly there were no users at that time, or the test cases were
insufficient to hit it.

The bug was then only noticed and fixed after
commit 9c2ba265352a ("drm/scheduler: use new iterator in drm_sched_job_add_implicit_dependencies v2")
landed, with its fixup of
commit 4eaf02d6076c ("drm/scheduler: fix drm_sched_job_add_implicit_dependencies").

At that point it was a slightly different flavour of a double free, which
commit 963d0b356935 ("drm/scheduler: fix drm_sched_job_add_implicit_dependencies harder")
noticed and attempted to fix.

But it only moved the double free from happening inside the
drm_sched_job_add_dependency(), when releasing the reference not yet
obtained, to the caller, when releasing the reference already released by
the former in the failure case.

As such it is not easy to identify the right target for the fixes tag so
lets keep it simple and just continue the chain.

While fixing we also improve the comment and explain the reason for taking
the reference and not dropping it.

## Which versions are affected by CVE-2025-40096?


## How do I fix CVE-2025-40096?

Apply the vendor's patch.

## Is CVE-2025-40096 being exploited?

There is no known exploitation of CVE-2025-40096 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2025-40096 and fix it if it is affected.

What it is: CVE-2025-40096 is a high-severity use after free vulnerability in Linux, published on 30 Oct 2025. It can only be exploited from the same machine or local network, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2025-40096 in the wild and no public exploit code.

Affected product: Linux. No package-level version data is available, so check the vendor advisory linked from the reference page.

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2025-40096/ (Markdown: https://insights.sbomify.com/CVE-2025-40096/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2025-40096
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2025-40096
- OSV: https://osv.dev/vulnerability/CVE-2025-40096

---
From sbomify Insights: https://insights.sbomify.com/CVE-2025-40096/
Summaries are generated and may contain mistakes; the official description above is the record.
