CVE-2024-50140

Source
https://cve.org/CVERecord?id=CVE-2024-50140
Import Source
https://storage.googleapis.com/osv-test-cve-osv-conversion/osv-output/CVE-2024-50140.json
JSON Data
https://api.test.osv.dev/v1/vulns/CVE-2024-50140
Downstream
Related
Published
2024-11-07T09:31:17.379Z
Modified
2026-03-20T12:39:35.950061Z
Severity
  • 5.5 (Medium) CVSS_V3 - CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H CVSS Calculator
Summary
sched/core: Disable page allocation in task_tick_mm_cid()
Details

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

sched/core: Disable page allocation in tasktickmm_cid()

With KASAN and PREEMPTRT enabled, calling taskworkadd() in tasktickmmcid() may cause the following splat.

[ 63.696416] BUG: sleeping function called from invalid context at kernel/locking/spinlockrt.c:48 [ 63.696416] inatomic(): 1, irqsdisabled(): 1, nonblock: 0, pid: 610, name: modprobe [ 63.696416] preempt_count: 10001, expected: 0 [ 63.696416] RCU nest depth: 1, expected: 1

This problem is caused by the following call trace.

sched_tick() [ acquire rq->__lock ] -> tasktickmmcid() -> taskwork_add() -> __kasanrecordauxstack() -> kasansavestack() -> stackdepotsaveflags() -> allocpagesmpol_noprof() -> __allocpagesnoprof() -> getpagefromfreelist() -> rmqueue() -> rmqueuepcplist() -> __rmqueuepcplist() -> rmqueuebulk() -> rtspinlock()

The rq lock is a rawspinlockt. We can't sleep while holding it. IOW, we can't call allocpages() in stackdepotsaveflags().

The tasktickmmcid() function with its taskworkadd() call was introduced by commit 223baf9d17f2 ("sched: Fix performance regression introduced by mmcid") in v6.4 kernel.

Fortunately, there is a kasanrecordauxstacknoalloc() variant that calls stackdepotsaveflags() while not allowing it to allocate new pages. To allow tasktickmmcid() to use taskwork without page allocation, a new TWAFNOALLOC flag is added to enable calling kasanrecordauxstacknoalloc() instead of kasanrecordauxstack() if set. The tasktickmm_cid() function is modified to add this new flag.

The possible downside is the missing stack trace in a KASAN report due to new page allocation required when taskworkadd_noallloc() is called which should be rare.

Database specific
{
    "osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2024/50xxx/CVE-2024-50140.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
223baf9d17f25e2608dbdff7232c095c1e612268
Fixed
509c29d0d26f68a6f6d0a05cb1a89725237e2b87
Fixed
ce0241ef83eed55f675376e8a3605d23de53d875
Fixed
73ab05aa46b02d96509cb029a8d04fca7bbde8c7

Database specific

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