w1: therm: Fix off-by-one buffer overflow in alarms_store
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
≥ e2c94d6f572079511945e64537eb1218643f2e68 · < e6b2609af21b5cccc9559339591b8a2cbf884169| No fix yet |
| Linux Linux |
|
|
In the Linux kernel, the following vulnerability has been resolved:
w1: therm: Fix off-by-one buffer overflow in alarms_store
The sysfs buffer passed to alarms_store() is allocated with 'size + 1' bytes and a NUL terminator is appended. However, the 'size' argument does not account for this extra byte. The original code then allocated 'size' bytes and used strcpy() to copy 'buf', which always writes one byte past the allocated buffer since strcpy() copies until the NUL terminator at index 'size'.
Fix this by parsing the 'buf' parameter directly using simple_strtoll() without allocating any intermediate memory or string copying. This removes the overflow while simplifying the code.
From the CVE record · Linux
The Linux kernel's w1 therm alarms_store() function copies a sysfs buffer into an allocation that is one byte too small. A local actor able to write to the affected sysfs attribute can trigger a one-byte buffer overflow; the input does not specify any further impact.
Engineers running Linux kernels with the w1 therm component should check their versions; affected versions are not specified.