linux/drivers/w1/slaves
Thorsten Blum e6b2609af2 w1: therm: Fix off-by-one buffer overflow in alarms_store
commit 761fcf46a1 upstream.

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.

Cc: stable@vger.kernel.org
Fixes: e2c94d6f57 ("w1_therm: adding alarm sysfs entry")
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Link: https://patch.msgid.link/20251216145007.44328-2-thorsten.blum@linux.dev
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2026-01-30 10:32:13 +01:00
..
Kconfig w1: Fix Kconfig indentation 2023-05-08 08:14:50 +02:00
Makefile w1: new driver. DS2430 chip 2019-11-14 13:06:33 +08:00
w1_ds28e04.c sysfs: treewide: switch back to attribute_group::bin_attrs 2025-06-17 10:44:15 +02:00
w1_ds28e17.c w1: core: use sysfs_emit() instead of sprintf() 2024-12-22 15:42:15 +01:00
w1_ds250x.c nvmem: add explicit config option to read old syntax fixed OF cells 2023-10-21 19:19:06 +02:00
w1_ds2405.c w1: Constify static w1_family_ops structs 2020-10-05 13:21:49 +02:00
w1_ds2406.c sysfs: treewide: switch back to bin_attribute::read()/write() 2025-06-17 10:44:13 +02:00
w1_ds2408.c sysfs: treewide: switch back to attribute_group::bin_attrs 2025-06-17 10:44:15 +02:00
w1_ds2413.c sysfs: treewide: switch back to attribute_group::bin_attrs 2025-06-17 10:44:15 +02:00
w1_ds2423.c w1: Constify static w1_family_ops structs 2020-10-05 13:21:49 +02:00
w1_ds2430.c sysfs: treewide: switch back to attribute_group::bin_attrs 2025-06-17 10:44:15 +02:00
w1_ds2431.c sysfs: treewide: switch back to attribute_group::bin_attrs 2025-06-17 10:44:15 +02:00
w1_ds2433.c sysfs: treewide: switch back to attribute_group::bin_attrs 2025-06-17 10:44:15 +02:00
w1_ds2438.c sysfs: treewide: switch back to attribute_group::bin_attrs 2025-06-17 10:44:15 +02:00
w1_ds2780.c sysfs: treewide: switch back to attribute_group::bin_attrs 2025-06-17 10:44:15 +02:00
w1_ds2780.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
w1_ds2781.c sysfs: treewide: switch back to attribute_group::bin_attrs 2025-06-17 10:44:15 +02:00
w1_ds2781.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
w1_ds2805.c sysfs: treewide: switch back to bin_attribute::read()/write() 2025-06-17 10:44:13 +02:00
w1_smem.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 94 2019-05-24 17:37:53 +02:00
w1_therm.c w1: therm: Fix off-by-one buffer overflow in alarms_store 2026-01-30 10:32:13 +01:00