CVE-2024-38613

Source
https://nvd.nist.gov/vuln/detail/CVE-2024-38613
Import Source
https://storage.googleapis.com/osv-test-cve-osv-conversion/osv-output/CVE-2024-38613.json
JSON Data
https://api.test.osv.dev/v1/vulns/CVE-2024-38613
Downstream
Related
Published
2024-06-19T13:56:14.083Z
Modified
2025-11-28T02:34:20.064489Z
Summary
m68k: Fix spinlock race in kernel thread creation
Details

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

m68k: Fix spinlock race in kernel thread creation

Context switching does take care to retain the correct lock owner across the switch from 'prev' to 'next' tasks. This does rely on interrupts remaining disabled for the entire duration of the switch.

This condition is guaranteed for normal process creation and context switching between already running processes, because both 'prev' and 'next' already have interrupts disabled in their saved copies of the status register.

The situation is different for newly created kernel threads. The status register is set to PSS in copythread(), which does leave the IPL at 0. Upon restoring the 'next' thread's status register in switchto() aka resume(), interrupts then become enabled prematurely. resume() then returns via retfromkernelthread() and scheduletail() where run queue lock is released (see finishtaskswitch() and finishlock_switch()).

A timer interrupt calling schedulertick() before the lock is released in finishtask_switch() will find the lock already taken, with the current task as lock owner. This causes a spinlock recursion warning as reported by Guenter Roeck.

As far as I can ascertain, this race has been opened in commit 533e6903bea0 ("m68k: split retfromfork(), simplify kernel_thread()") but I haven't done a detailed study of kernel history so it may well predate that commit.

Interrupts cannot be disabled in the saved status register copy for kernel threads (init will complain about interrupts disabled when finally starting user space). Disable interrupts temporarily when switching the tasks' register sets in resume().

Note that a simple oriw 0x700,%sr after restoring sr is not enough here - this leaves enough of a race for the 'spinlock recursion' warning to still be observed.

Tested on ARAnyM and qemu (Quadra 800 emulation).

Database specific
{
    "cna_assigner": "Linux",
    "osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2024/38xxx/CVE-2024-38613.json"
}
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
533e6903bea0440816a0f517b0845ccea4cc7917
Fixed
2a8d1d95302c7d52c6ac8fa5cb4a6948ae0d3a14
Fixed
5213cc01d0464c011fdc09f318705603ed3a746b
Fixed
4eeffecc8e3cce25bb559502c2fd94a948bcde82
Fixed
77b2b67a0f8bce260c53907e5749d61466d90c87
Fixed
0d9ae1253535f6e85a016e09c25ecbe6f7f59ef0
Fixed
f3baf0f4f92af32943ebf27b960e0552c6c082fd
Fixed
f1d4274a84c069be0f6098ab10c3443fc1f7134c
Fixed
95f00caf767b5968c2c51083957b38be4748a78a
Fixed
da89ce46f02470ef08f0f580755d14d547da59ed

Linux / Kernel

Package

Name
Kernel

Affected ranges

Type
ECOSYSTEM
Events
Introduced
3.7.0
Fixed
4.19.316
Type
ECOSYSTEM
Events
Introduced
4.20.0
Fixed
5.4.278
Type
ECOSYSTEM
Events
Introduced
5.5.0
Fixed
5.10.219
Type
ECOSYSTEM
Events
Introduced
5.11.0
Fixed
5.15.161
Type
ECOSYSTEM
Events
Introduced
5.16.0
Fixed
6.1.93
Type
ECOSYSTEM
Events
Introduced
6.2.0
Fixed
6.6.33
Type
ECOSYSTEM
Events
Introduced
6.7.0
Fixed
6.8.12
Type
ECOSYSTEM
Events
Introduced
6.9.0
Fixed
6.9.3