In the Linux kernel, the following vulnerability has been resolved:
media: rainshadow-cec: fix TOCTOU race condition in rain_interrupt()
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 rainirqwork_handler() 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 (DATA_SIZE) 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.
[
{
"signature_type": "Function",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@7af160aea26c7dc9e6734d19306128cce156ec40",
"signature_version": "v1",
"id": "CVE-2025-39713-05aeeb89",
"digest": {
"function_hash": "50946748883526243136926667811539013753",
"length": 466.0
},
"target": {
"function": "rain_interrupt",
"file": "drivers/media/cec/usb/rainshadow/rainshadow-cec.c"
}
},
{
"signature_type": "Line",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@2964dbe631fd21ad7873b1752b895548d3c12496",
"signature_version": "v1",
"id": "CVE-2025-39713-24501541",
"digest": {
"threshold": 0.9,
"line_hashes": [
"271201318959172648978308228991260945951",
"119263556743618273744136475730012619099",
"321374481842955872771869740847273229651",
"247740646939200546308353399848375175619",
"222658052100991524028279890738426130540",
"267684165648698538879163019607675249822",
"40064394208633805454036331006194466976",
"272764989456732159782738226084090625895"
]
},
"target": {
"file": "drivers/media/usb/rainshadow-cec/rainshadow-cec.c"
}
},
{
"signature_type": "Function",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@1c2769dc80255824542ea5a4ff1a07dcdeb1603f",
"signature_version": "v1",
"id": "CVE-2025-39713-28f60ba6",
"digest": {
"function_hash": "50946748883526243136926667811539013753",
"length": 466.0
},
"target": {
"function": "rain_interrupt",
"file": "drivers/media/cec/usb/rainshadow/rainshadow-cec.c"
}
},
{
"signature_type": "Function",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@ff9dd3db6cd4c6b54a2ecbc58151bea4ec63bc59",
"signature_version": "v1",
"id": "CVE-2025-39713-39f9fabd",
"digest": {
"function_hash": "50946748883526243136926667811539013753",
"length": 466.0
},
"target": {
"function": "rain_interrupt",
"file": "drivers/media/cec/usb/rainshadow/rainshadow-cec.c"
}
},
{
"signature_type": "Line",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@1c2769dc80255824542ea5a4ff1a07dcdeb1603f",
"signature_version": "v1",
"id": "CVE-2025-39713-3aee0f8e",
"digest": {
"threshold": 0.9,
"line_hashes": [
"271201318959172648978308228991260945951",
"119263556743618273744136475730012619099",
"321374481842955872771869740847273229651",
"247740646939200546308353399848375175619",
"222658052100991524028279890738426130540",
"267684165648698538879163019607675249822",
"40064394208633805454036331006194466976",
"272764989456732159782738226084090625895"
]
},
"target": {
"file": "drivers/media/cec/usb/rainshadow/rainshadow-cec.c"
}
},
{
"signature_type": "Function",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@6aaef1a75985865d8c6c5b65fb54152060faba48",
"signature_version": "v1",
"id": "CVE-2025-39713-45357185",
"digest": {
"function_hash": "50946748883526243136926667811539013753",
"length": 466.0
},
"target": {
"function": "rain_interrupt",
"file": "drivers/media/cec/usb/rainshadow/rainshadow-cec.c"
}
},
{
"signature_type": "Function",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@2964dbe631fd21ad7873b1752b895548d3c12496",
"signature_version": "v1",
"id": "CVE-2025-39713-7cea0774",
"digest": {
"function_hash": "50946748883526243136926667811539013753",
"length": 466.0
},
"target": {
"function": "rain_interrupt",
"file": "drivers/media/usb/rainshadow-cec/rainshadow-cec.c"
}
},
{
"signature_type": "Line",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@7af160aea26c7dc9e6734d19306128cce156ec40",
"signature_version": "v1",
"id": "CVE-2025-39713-97509b32",
"digest": {
"threshold": 0.9,
"line_hashes": [
"271201318959172648978308228991260945951",
"119263556743618273744136475730012619099",
"321374481842955872771869740847273229651",
"247740646939200546308353399848375175619",
"222658052100991524028279890738426130540",
"267684165648698538879163019607675249822",
"40064394208633805454036331006194466976",
"272764989456732159782738226084090625895"
]
},
"target": {
"file": "drivers/media/cec/usb/rainshadow/rainshadow-cec.c"
}
},
{
"signature_type": "Line",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@6aaef1a75985865d8c6c5b65fb54152060faba48",
"signature_version": "v1",
"id": "CVE-2025-39713-c14e5901",
"digest": {
"threshold": 0.9,
"line_hashes": [
"271201318959172648978308228991260945951",
"119263556743618273744136475730012619099",
"321374481842955872771869740847273229651",
"247740646939200546308353399848375175619",
"222658052100991524028279890738426130540",
"267684165648698538879163019607675249822",
"40064394208633805454036331006194466976",
"272764989456732159782738226084090625895"
]
},
"target": {
"file": "drivers/media/cec/usb/rainshadow/rainshadow-cec.c"
}
},
{
"signature_type": "Function",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@3c3e33b7edca7a2d6a96801f287f9faeb684d655",
"signature_version": "v1",
"id": "CVE-2025-39713-e5fcc58c",
"digest": {
"function_hash": "50946748883526243136926667811539013753",
"length": 466.0
},
"target": {
"function": "rain_interrupt",
"file": "drivers/media/cec/usb/rainshadow/rainshadow-cec.c"
}
},
{
"signature_type": "Line",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@3c3e33b7edca7a2d6a96801f287f9faeb684d655",
"signature_version": "v1",
"id": "CVE-2025-39713-f7988762",
"digest": {
"threshold": 0.9,
"line_hashes": [
"271201318959172648978308228991260945951",
"119263556743618273744136475730012619099",
"321374481842955872771869740847273229651",
"247740646939200546308353399848375175619",
"222658052100991524028279890738426130540",
"267684165648698538879163019607675249822",
"40064394208633805454036331006194466976",
"272764989456732159782738226084090625895"
]
},
"target": {
"file": "drivers/media/cec/usb/rainshadow/rainshadow-cec.c"
}
},
{
"signature_type": "Line",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@ff9dd3db6cd4c6b54a2ecbc58151bea4ec63bc59",
"signature_version": "v1",
"id": "CVE-2025-39713-ff476eb3",
"digest": {
"threshold": 0.9,
"line_hashes": [
"271201318959172648978308228991260945951",
"119263556743618273744136475730012619099",
"321374481842955872771869740847273229651",
"247740646939200546308353399848375175619",
"222658052100991524028279890738426130540",
"267684165648698538879163019607675249822",
"40064394208633805454036331006194466976",
"272764989456732159782738226084090625895"
]
},
"target": {
"file": "drivers/media/cec/usb/rainshadow/rainshadow-cec.c"
}
}
]