CVE-2025-21767

Source
https://cve.org/CVERecord?id=CVE-2025-21767
Import Source
https://storage.googleapis.com/osv-test-cve-osv-conversion/osv-output/CVE-2025-21767.json
JSON Data
https://api.test.osv.dev/v1/vulns/CVE-2025-21767
Downstream
Related
Published
2025-02-27T02:18:17.067Z
Modified
2026-03-20T12:41:09.696325Z
Summary
clocksource: Use migrate_disable() to avoid calling get_random_u32() in atomic context
Details

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

clocksource: Use migratedisable() to avoid calling getrandom_u32() in atomic context

The following bug report happened with a PREEMPT_RT kernel:

BUG: sleeping function called from invalid context at kernel/locking/spinlockrt.c:48 inatomic(): 1, irqsdisabled(): 0, nonblock: 0, pid: 2012, name: kwatchdog preemptcount: 1, expected: 0 RCU nest depth: 0, expected: 0 getrandomu32+0x4f/0x110 clocksourceverifychoosecpus+0xab/0x1a0 clocksourceverifypercpu.part.0+0x6b/0x330 clocksourcewatchdogkthread+0x193/0x1a0

It is due to the fact that clocksourceverifychoosecpus() is invoked with preemption disabled. This function invokes getrandomu32() to obtain random numbers for choosing CPUs. The batchedentropy32 local lock and/or the basecrng.lock spinlock in driver/char/random.c will be acquired during the call. In PREEMPT_RT kernel, they are both sleeping locks and so cannot be acquired in atomic context.

Fix this problem by using migratedisable() to allow smpprocessorid() to be reliably used without introducing atomic context. preemptdisable() is then called after clocksourceverifychoose_cpus() but before the clocksource measurement is being run to avoid introducing unexpected latency.

Database specific
{
    "osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2025/21xxx/CVE-2025-21767.json",
    "cna_assigner": "Linux"
}
References

Affected packages

Git / git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git

Affected ranges

Type
GIT
Repo
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
Events
Introduced
d9b40ebd448e437ffbc65f013836f98252279a82
Fixed
d9c217fadfcff7a8df58567517d1e4253f3fd243
Type
GIT
Repo
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
Events
Introduced
7560c02bdffb7c52d1457fa551b9e745d4b9e754
Fixed
60f54f0d4ea530950549a8263e6fdd70a40490a4
Fixed
852805b6cbdb69c298a8fc9fbe79994c95106e04
Fixed
8783ceeee797d9aa9cfe150690fb9d0bac8cc459
Fixed
cc3d79e7c806cb57d71c28a4a35e7d7fb3265faa
Fixed
0fb534187d2355f6c8f995321e76d1ccd1262ac1
Fixed
6bb05a33337b2c842373857b63de5c9bf1ae2a09
Type
GIT
Repo
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
Events
Introduced
0 Unknown introduced commit / All previous commits are affected
Last affected
193e14e68e907b2a7a936a7726accbaa4df25a4d
Last affected
155d3c5d24ee13cafa6236b49fc02b240a511d59

Database specific

source
"https://storage.googleapis.com/osv-test-cve-osv-conversion/osv-output/CVE-2025-21767.json"