# CVE-2025-21825: bpf: Cancel the running bpf\_timer through kworker for PREEMPT\_RT

> Archived entry. Full-text search covers entries since 2026-11-10; exact IDs work for all years.

- **Severity:** HIGH 7.8
- **CVSS:** 7.8 (v3.1, CNA) `CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H`
- **CVSS metrics:** Attack vector: Local; Attack complexity: Low; Privileges required: Low; User interaction: None; Scope: Unchanged; Confidentiality impact: High; Integrity impact: High; Availability impact: High
- **Exploited in the wild:** Not in CISA KEV
- **Public exploit / PoC:** None known
- **Remote exploitation:** Not remotely exploitable (local or adjacent access needed)
- **EPSS:** 0.29% (percentile 14, 2026-11-26)
- **CWE:** CWE-415
- **Published:** 2025-03-06T16:04:31.576Z
- **Modified:** 2026-10-21T13:17:58.700Z

## Who should check

- Anyone running Linux \>= b00628b1c7d595ae5b544e059c27b1f5828314b4, \< 50e44aa5f9905d237c245b8012937ef4dd971dcb; \>= b00628b1c7d595ae5b544e059c27b1f5828314b4, \< 33e47d9573075342a41783a55c8c67bc71246fc1; \>= b00628b1c7d595ae5b544e059c27b1f5828314b4, \< fbeda3d939ca10063aafa7a77cc0f409d82cda88; \>= b00628b1c7d595ae5b544e059c27b1f5828314b4, \< 58f038e6d209d2dd862fcf5de55407855856794d
- Anyone running Linux 5.15

## Description

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

bpf: Cancel the running bpf\_timer through kworker for PREEMPT\_RT

During the update procedure, when overwrite element in a pre-allocated
htab, the freeing of old\_element is protected by the bucket lock. The
reason why the bucket lock is necessary is that the old\_element has
already been stashed in htab-\>extra\_elems after alloc\_htab\_elem()
returns. If freeing the old\_element after the bucket lock is unlocked,
the stashed element may be reused by concurrent update procedure and the
freeing of old\_element will run concurrently with the reuse of the
old\_element. However, the invocation of check\_and\_free\_fields() may
acquire a spin-lock which violates the lockdep rule because its caller
has already held a raw-spin-lock (bucket lock). The following warning
will be reported when such race happens:

  BUG: scheduling while atomic: test\_progs/676/0x00000003
  3 locks held by test\_progs/676:
  \#0: ffffffff864b0240 (rcu\_read\_lock\_trace){....}-{0:0}, at: bpf\_prog\_test\_run\_syscall+0x2c0/0x830
  \#1: ffff88810e961188 (&htab-\>lockdep\_key){....}-{2:2}, at: htab\_map\_update\_elem+0x306/0x1500
  \#2: ffff8881f4eac1b8 (&base-\>softirq\_expiry\_lock){....}-{2:2}, at: hrtimer\_cancel\_wait\_running+0xe9/0x1b0
  Modules linked in: bpf\_testmod(O)
  Preemption disabled at:
  \[\<ffffffff817837a3\>\] htab\_map\_update\_elem+0x293/0x1500
  CPU: 0 UID: 0 PID: 676 Comm: test\_progs Tainted: G ... 6.12.0+ \#11
  Tainted: \[W\]=WARN, \[O\]=OOT\_MODULE
  Hardware name: QEMU Standard PC (i440FX + PIIX, 1996)...
  Call Trace:
  \<TASK\>
  dump\_stack\_lvl+0x57/0x70
  dump\_stack+0x10/0x20
  \_\_schedule\_bug+0x120/0x170
  \_\_schedule+0x300c/0x4800
  schedule\_rtlock+0x37/0x60
  rtlock\_slowlock\_locked+0x6d9/0x54c0
  rt\_spin\_lock+0x168/0x230
  hrtimer\_cancel\_wait\_running+0xe9/0x1b0
  hrtimer\_cancel+0x24/0x30
  bpf\_timer\_delete\_work+0x1d/0x40
  bpf\_timer\_cancel\_and\_free+0x5e/0x80
  bpf\_obj\_free\_fields+0x262/0x4a0
  check\_and\_free\_fields+0x1d0/0x280
  htab\_map\_update\_elem+0x7fc/0x1500
  bpf\_prog\_9f90bc20768e0cb9\_overwrite\_cb+0x3f/0x43
  bpf\_prog\_ea601c4649694dbd\_overwrite\_timer+0x5d/0x7e
  bpf\_prog\_test\_run\_syscall+0x322/0x830
  \_\_sys\_bpf+0x135d/0x3ca0
  \_\_x64\_sys\_bpf+0x75/0xb0
  x64\_sys\_call+0x1b5/0xa10
  do\_syscall\_64+0x3b/0xc0
  entry\_SYSCALL\_64\_after\_hwframe+0x4b/0x53
  ...
  \</TASK\>

It seems feasible to break the reuse and refill of per-cpu extra\_elems
into two independent parts: reuse the per-cpu extra\_elems with bucket
lock being held and refill the old\_element as per-cpu extra\_elems after
the bucket lock is unlocked. However, it will make the concurrent
overwrite procedures on the same CPU return unexpected -E2BIG error when
the map is full.

Therefore, the patch fixes the lock problem by breaking the cancelling
of bpf\_timer into two steps for PREEMPT\_RT:
1) use hrtimer\_try\_to\_cancel() and check its return value
2) if the timer is running, use hrtimer\_cancel() through a kworker to
   cancel it again
Considering that the current implementation of hrtimer\_cancel() will try
to acquire a being held softirq\_expiry\_lock when the current timer is
running, these steps above are reasonable. However, it also has
downside. When the timer is running, the cancelling of the timer is
delayed when releasing the last map uref. The delay is also fixable
(e.g., break the cancelling of bpf timer into two parts: one part in
locked scope, another one in unlocked scope), it can be revised later if
necessary.

It is a bit hard to decide the right fix tag. One reason is that the
problem depends on PREEMPT\_RT which is enabled in v6.12. Considering the
softirq\_expiry\_lock lock exists since v5.4 and bpf\_timer is introduced
in v5.15, the bpf\_timer commit is used in the fixes tag and an extra
depends-on tag is added to state the dependency on PREEMPT\_RT.

Depends-on: v6.12+ with PREEMPT\_RT enabled

## Affected and fixed versions

- Linux: \>= b00628b1c7d595ae5b544e059c27b1f5828314b4, \< 50e44aa5f9905d237c245b8012937ef4dd971dcb; \>= b00628b1c7d595ae5b544e059c27b1f5828314b4, \< 33e47d9573075342a41783a55c8c67bc71246fc1; \>= b00628b1c7d595ae5b544e059c27b1f5828314b4, \< fbeda3d939ca10063aafa7a77cc0f409d82cda88; \>= b00628b1c7d595ae5b544e059c27b1f5828314b4, \< 58f038e6d209d2dd862fcf5de55407855856794d (cvelist)
- Linux: 5.15 (cvelist)

## Mitigation

- Upgrade Linux to 58f038e6d209d2dd862fcf5de55407855856794d or later.

## Check your systems with an agent

Paste this into a coding agent:

```text
Check whether anything I run is affected by CVE-2025-21825. Work read-only: do not install, upgrade, delete or change anything.

Details: https://flawdb.com/CVE-2025-21825.md
Affected: Linux >= b00628b1c7d595ae5b544e059c27b1f5828314b4, < 50e44aa5f9905d237c245b8012937ef4dd971dcb; >= b00628b1c7d595ae5b544e059c27b1f5828314b4, < 33e47d9573075342a41783a55c8c67bc71246fc1; >= b00628b1c7d595ae5b544e059c27b1f5828314b4, < fbeda3d939ca10063aafa7a77cc0f409d82cda88; >= b00628b1c7d595ae5b544e0…
Fixed in: Linux 50e44aa5f9905d237c245b8012937ef4dd971dcb, Linux 33e47d9573075342a41783a55c8c67bc71246fc1, Linux 58f038e6d209d2dd862fcf5de55407855856794d

Steps:
1. Search this machine and project for Linux: dependency manifests and lockfiles, installed packages, container images and running services.
2. For each match, note the installed version and whether it is inside the affected range.
3. Report a table: location, installed version, affected (yes / no / unsure), evidence. If affected, say which fixed version or mitigation from the details link applies, but don't apply it.
```

## FAQ

### Is CVE-2025-21825 being exploited?

There is no confirmed exploitation: CVE-2025-21825 is not in the CISA Known Exploited Vulnerabilities catalog. No public exploit code is known. EPSS estimates a 0.29% chance of exploitation in the next 30 days (as of 2026-11-26).

### How serious is CVE-2025-21825?

High: CVSS 7.8 (v3.1, scored by CNA). Not remotely exploitable (local or adjacent access needed).

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

Linux \>= b00628b1c7d595ae5b544e059c27b1f5828314b4, \< 50e44aa5f9905d237c245b8012937ef4dd971dcb; \>= b00628b1c7d595ae5b544e059c27b1f5828314b4, \< 33e47d9573075342a41783a55c8c67bc71246fc1; \>= b00628b1c7d595ae5b544e059c27b1f5828314b4, \< fbeda3d939ca10063aafa7a77cc0f409d82cda88; \>= b00628b1c7d595ae5b544e059c27b1f5828314b4, \< 58f038e6d209d2dd862fcf5de55407855856794d; Linux 5.15.

### Is there a fix for CVE-2025-21825?

Yes. Fixed in Linux 50e44aa5f9905d237c245b8012937ef4dd971dcb, Linux 33e47d9573075342a41783a55c8c67bc71246fc1, Linux 58f038e6d209d2dd862fcf5de55407855856794d. Upgrade Linux to 58f038e6d209d2dd862fcf5de55407855856794d or later.

### How do I check if I'm affected by CVE-2025-21825?

Find where you use the affected software (dependency lockfiles, installed packages, container images, servers) and compare the installed version with the affected range above. The agent prompt on this page does this read-only.

## References

- patch: <https://git.kernel.org/stable/c/33e47d9573075342a41783a55c8c67bc71246fc1>
- patch: <https://git.kernel.org/stable/c/fbeda3d939ca10063aafa7a77cc0f409d82cda88>
- patch: <https://git.kernel.org/stable/c/58f038e6d209d2dd862fcf5de55407855856794d>
- other: <https://git.kernel.org/stable/c/50e44aa5f9905d237c245b8012937ef4dd971dcb>

## Attribution

- CVE Program: CVE® is a registered trademark of The MITRE Corporation. CVE records © 1999–2026 The MITRE Corporation. <https://www.cve.org/Legal/TermsOfUse>
- NVD: This product uses data from the NVD API but is not endorsed or certified by the NVD. <https://nvd.nist.gov/vuln/detail/CVE-2025-21825>

HTML: <https://flawdb.com/CVE-2025-21825> · JSON: <https://flawdb.com/api/v1/entries/CVE-2025-21825>
