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 treewide: rename GPIO set callbacks back to their original names 2025-08-07 10:07:06 +02:00
afe iio: normalize array sentinel style 2025-04-22 19:10:04 +01:00
amplifiers iio: amplifiers: ad8366: make ad8366_info const 2025-07-06 10:37:52 +01:00
buffer Char/Misc/IIO driver updates for 6.19-rc1 2025-12-06 18:34:24 -08:00
cdc iio: normalize array sentinel style 2025-04-22 19:10:04 +01:00
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 iio: dummy: Switch to iio_push_to_buffers_with_ts() and provide size of storage 2025-05-21 14:20:26 +01:00
filter iio: normalize array sentinel style 2025-04-22 19:10:04 +01:00
frequency IIO: New device support, features and cleanup for 6.18 2025-09-23 14:15:25 +02:00
gyro iio: gyro: Remove redundant pm_runtime_mark_last_busy() calls 2025-08-25 16:04:47 +01:00
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 iio: magnetometer: tmag5273: remove unused IIO_CHAN_INFO_PROCESSED handling 2025-09-10 19:47:06 +01:00
multiplexer iio: normalize array sentinel style 2025-04-22 19:10:04 +01:00
orientation iio: orientation: hid-sensor-rotation: remove unnecessary alignment 2025-05-21 14:20:28 +01:00
position iio: position: hid-sensor-custom-intel-hinge: replace sprintf() with sysfs_emit() 2025-10-19 11:59:18 +01:00
potentiometer iio: potentiometer: Drop unused export.h includes 2025-06-26 19:32:52 +01:00
potentiostat iio: potentiostat: Drop unnecessary -ENOMEM messages 2025-08-25 12:36:29 +01:00
pressure Char/Misc/IIO driver updates for 6.19-rc1 2025-12-06 18:34:24 -08:00
proximity Linux 6.17-rc3 2025-09-13 15:00:48 +01:00
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 iio: test: Add KUnit tests for iio_multiply_value() 2025-09-10 19:47:05 +01:00
trigger iio: trigger: stm32-lptimer: Fix build warnings about export.h 2025-06-26 19:32:52 +01:00
iio_core.h iio: Add iio_read_channel_label to inkern API 2024-06-28 20:06:56 +01:00
iio_core_trigger.h
industrialio-acpi.c iio: acpi: Add iio_get_acpi_device_name_and_data() helper function 2024-10-28 20:04:11 +00:00
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 iio: introduce the FAULT event type 2025-02-08 15:16:29 +00:00
industrialio-gts-helper.c iio: gts-helper: export iio_gts_get_total_gain() 2025-02-08 15:16:29 +00:00
industrialio-sw-device.c
industrialio-sw-trigger.c
industrialio-trigger.c iio: trigger: allow devices to suspend/resume theirs associated trigger 2024-08-10 11:19:36 +01:00
industrialio-triggered-event.c
inkern.c iio: Improve iio_read_channel_processed_scale() precision 2025-09-10 19:47:04 +01:00
Kconfig iio: core: Add new DMABUF interface infrastructure 2024-06-30 11:29:17 +01:00
Makefile iio: core: Add iio_read_acpi_mount_matrix() helper function 2024-04-29 20:53:25 +01:00
TODO