4.7medium
hwmon: (ftsteutates) Fix TOCTOU race in fts_read()
- Severity
- 4.7medium CVSS:3.1 by NVD
- Exploit likelihood
- 0.13% (higher than 2% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- Linux
Description
In the Linux kernel, the following vulnerability has been resolved: hwmon: (ftsteutates) Fix TOCTOU race in fts_read() In the fts_read() function, when handling hwmon_pwm_auto_channels_temp, the code accesses the shared variable data->fan_source[channel] twice without holding any locks. It is first checked against FTS_FAN_SOURCE_INVALID, and if the check passes, it is read again when used as an argument to the BIT() macro. This creates a Time-of-Check to Time-of-Use (TOCTOU) race condition. Another thread executing fts_update_device() can modify the value of data->fan_source[channel] between the check and its use. If the value is changed to FTS_FAN_SOURCE_INVALID (0xff) during this window, the BIT() macro will be called with a large shift value (BIT(255)). A bit shift by a value greater than or equal to the type width is undefined behavior and can lead to a crash or incorrect values being returned to userspace. Fix this by reading data->fan_source[channel] into a local variable once, eliminating the race condition. Additionally, add a bounds check to ensure the value is less than BITS_PER_LONG before passing it to the BIT() macro, making the code more robust against undefined behavior. This possible bug was found by an experimental static analysis tool developed by our team.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| Linux Linux | from 1c5759d8ce054961b454af69568a41e7e3210ee1 before d95d87841d2a575bed3691884e8fedef57d7710d, from 1c5759d8ce054961b454af69568a41e7e3210ee1 before 83e2ba8971ccd8fc08319fc7593288f070d80a76, from 1c5759d8ce054961b454af69568a41e7e3210ee1 before 4d646f627d3b7ed1cacca66e598af8bcd632d465, from 1c5759d8ce054961b454af69568a41e7e3210ee1 before 14c9ede9ca4cd078ad76a6ab9617b81074eb58bf, 6.3 Not affected: before 6.3, from 6.6.95 up to 6.6.*, from 6.12.35 up to 6.12.*, from 6.15.4 up to 6.15.*, from 6.16 up to * | CVE List |
| linux linux_kernel | from 6.3 before 6.6.95, from 6.7 before 6.12.35, from 6.13 before 6.15.4, 6.16 | NVD |
Classification
What each source says
CVE List
In the Linux kernel, the following vulnerability has been resolved: hwmon: (ftsteutates) Fix TOCTOU race in fts_read() In the fts_read() function, when handling hwmon_pwm_auto_channels_temp, the code accesses the shared variable data->fan_source[channel] twice without holding any locks. It is first checked against FTS_FAN_SOURCE_INVALID, and if the check passes, it is read again when used as an argument to the BIT() macro. This creates a Time-of-Check to Time-of-Use (TOCTOU) race condition. Another thread executing fts_update_device() can modify the value of data->fan_source[channel] between the check and its use. If the value is changed to FTS_FAN_SOURCE_INVALID (0xff) during this window, the BIT() macro will be called with a large shift value (BIT(255)). A bit shift by a value greater than or equal to the type width is undefined behavior and can lead to a crash or incorrect values being returned to userspace. Fix this by reading data->fan_source[channel] into a local variable once, eliminating the race condition. Additionally, add a bounds check to ensure the value is less than BITS_PER_LONG before passing it to the BIT() macro, making the code more robust against undefined behavior. This possible bug was found by an experimental static analysis tool developed by our team.
NVD (es)
En el kernel de Linux, se ha resuelto la siguiente vulnerabilidad: hwmon: (ftsteutates) Corregir la ejecución TOCTOU en fts_read() En la función fts_read(), al manejar hwmon_pwm_auto_channels_temp, el código accede a la variable compartida data->fan_source[channel] dos veces sin mantener ningún bloqueo. Primero se compara con FTS_FAN_SOURCE_INVALID y, si la comprobación es correcta, se vuelve a leer cuando se usa como argumento de la macro BIT(). Esto crea una condición de ejecución de tiempo de comprobación a tiempo de uso (TOCTOU). Otro hilo que ejecute fts_update_device() puede modificar el valor de data->fan_source[channel] entre la comprobación y su uso. Si el valor se cambia a FTS_FAN_SOURCE_INVALID (0xff) durante esta ventana, se llamará a la macro BIT() con un valor de desplazamiento grande (BIT(255)). Un desplazamiento de bits por un valor mayor o igual al ancho del tipo es un comportamiento indefinido que puede provocar un fallo o la devolución de valores incorrectos al espacio de usuario. Para solucionarlo, lea data->fan_source[channel] en una variable local una vez, eliminando así la condición de ejecución. Además, añada una comprobación de los límites para garantizar que el valor sea menor que BITS_PER_LONG antes de pasarlo a la macro BIT(), lo que aumenta la robustez del código frente a comportamientos indefinidos. Este posible error fue detectado por una herramienta de análisis estático experimental desarrollada por nuestro equipo.
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2025-38217 changed 2026-05-11 | CVE Terms of Use |
| NVD | CVE-2025-38217 changed 2026-06-17 | Public domain |