linux/drivers/iio
Miaoqian Lin 978d28136c iio: dac: ad3552r-hs: fix out-of-bound write in ad3552r_hs_write_data_source
When simple_write_to_buffer() succeeds, it returns the number of bytes
actually copied to the buffer. The code incorrectly uses 'count'
as the index for null termination instead of the actual bytes copied.
If count exceeds the buffer size, this leads to out-of-bounds write.
Add a check for the count and use the return value as the index.

The bug was validated using a demo module that mirrors the original
code and was tested under QEMU.

Pattern of the bug:
- A fixed 64-byte stack buffer is filled using count.
- If count > 64, the code still does buf[count] = '\0', causing an
- out-of-bounds write on the stack.

Steps for reproduce:
- Opens the device node.
- Writes 128 bytes of A to it.
- This overflows the 64-byte stack buffer and KASAN reports the OOB.

Found via static analysis. This is similar to the
commit da9374819e ("iio: backend: fix out-of-bound write")

Fixes: b1c5d68ea6 ("iio: dac: ad3552r-hs: add support for internal ramp")
Cc: stable@vger.kernel.org
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2026-01-11 13:25:15 +00:00
..
accel iio: accel: iis328dq: fix gain values 2026-01-11 12:00:08 +00:00
adc iio: adc: exynos_adc: fix OF populate on driver rebind 2025-12-21 17:00:30 +00:00
addac
afe
amplifiers
buffer Char/Misc/IIO driver updates for 6.19-rc1 2025-12-06 18:34:24 -08:00
cdc
chemical iio: chemical: scd4x: fix reported channel endianness 2025-12-21 19:04:03 +00:00
common Char/Misc/IIO driver updates for 6.19-rc1 2025-12-06 18:34:24 -08:00
dac iio: dac: ad3552r-hs: fix out-of-bound write in ad3552r_hs_write_data_source 2026-01-11 13:25:15 +00:00
dummy
filter
frequency IIO: New device support, features and cleanup for 6.18 2025-09-23 14:15:25 +02:00
gyro
health iio: health: max30100: Make LED pulse-width configurable via DT 2025-10-19 11:59:22 +01:00
humidity iio: humditiy: hdc3020: fix units for thresholds and hysteresis 2025-10-19 11:46:24 +01:00
imu iio: imu: inv_icm45600: fix temperature offset reporting 2025-12-21 18:40:56 +00:00
light iio: light: apds9960: convert to use maple tree register cache 2025-11-09 12:57:05 +00:00
magnetometer
multiplexer
orientation
position iio: position: hid-sensor-custom-intel-hinge: replace sprintf() with sysfs_emit() 2025-10-19 11:59:18 +01:00
potentiometer
potentiostat
pressure Char/Misc/IIO driver updates for 6.19-rc1 2025-12-06 18:34:24 -08:00
proximity
resolver iio: resolver: ad2s1210: replace sprintf() with sysfs_emit() 2025-10-19 11:59:18 +01:00
temperature iio: mlx90614: Convert to common field_{get,prep}() helpers 2025-11-24 14:15:47 -05:00
test
trigger
Kconfig
Makefile
TODO
iio_core.h
iio_core_trigger.h
industrialio-acpi.c
industrialio-backend.c iio: backend: fix kernel-doc to avoid warnings and ensure consistency 2025-11-09 12:57:05 +00:00
industrialio-buffer.c Char/Misc/IIO driver updates for 6.19-rc1 2025-12-06 18:34:24 -08:00
industrialio-configfs.c
industrialio-core.c iio: core: add separate lockdep class for info_exist_lock 2025-12-27 14:56:33 +00:00
industrialio-event.c
industrialio-gts-helper.c
industrialio-sw-device.c
industrialio-sw-trigger.c
industrialio-trigger.c
industrialio-triggered-event.c
inkern.c