CVE-2025-39713: media: rainshadow-cec: fix TOCTOU race condition in rain_interrupt()
In the Linux kernel, the following vulnerability has been resolved:
media: rainshadow-cec: fix TOCTOU race condition in raininterrupt()
In the interrupt handler raininterrupt(), the buffer full check on rain->buflen is performed before acquiring rain->buflock. This creates a Time-of-Check to Time-of-Use (TOCTOU) race condition, as rain->buflen is concurrently accessed and modified in the work handler rainirqworkhandler() under the same lock.
Multiple interrupt invocations can race, with each reading buflen before it becomes full and then proceeding. This can lead to both interrupts attempting to write to the buffer, incrementing buflen beyond its capacity (DATASIZE) and causing a buffer overflow.
Fix this bug by moving the spinlock() to before the buffer full check. This ensures that the check and the subsequent buffer modification are performed atomically, preventing the race condition. An corresponding spinunlock() is added to the overflow path to correctly release the lock.
This possible bug was found by an experimental static analysis tool developed by our team.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
debian/linuxto a version that resolves this vulnerability.Fixed in 6.1.176-1Fixed in 6.1.190-1Fixed in 6.12.107-1Fixed in 6.12.113-1Fixed in 7.2.12-1Fixed in 7.2.13-1 - Configuration
Move spin_lock() for rain->buf_lock before the buffer-full check in rain_interrupt(), and add the corresponding spin_unlock() on the overflow path so the check and buffer modification are performed atomically.
Linux kernel media: rainshadow-cec rain->buf_lock acquisition order = Acquire rain->buf_lock before checking rain->buf_len
Event History
Frequently Asked Questions
What is the severity of CVE-2025-39713?
CVE-2025-39713 is classified as a medium severity vulnerability in the Linux kernel.
How do I fix CVE-2025-39713?
To fix CVE-2025-39713, update to the latest version of the Linux kernel where the vulnerability has been addressed.
What components are affected by CVE-2025-39713?
CVE-2025-39713 affects the media subsystem, specifically the rainshadow-cec driver in the Linux kernel.
What type of vulnerability is CVE-2025-39713?
CVE-2025-39713 is a time-of-check to time-of-use (TOCTOU) race condition vulnerability.
Which systems are at risk due to CVE-2025-39713?
Any system running an affected version of the Linux kernel with the rainshadow-cec media driver is at risk from CVE-2025-39713.