]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
iio: pressure: bmp280: zero-init bmp580 trigger handler buffer
authorDavid Carlier <devnexen@gmail.com>
Tue, 5 May 2026 17:34:55 +0000 (18:34 +0100)
committerJonathan Cameron <jic23@kernel.org>
Sat, 16 May 2026 10:23:58 +0000 (11:23 +0100)
bmp580_trigger_handler() builds an on-stack scan buffer containing
two __le32 fields and an aligned_s64 timestamp, and pushes it to
userspace via iio_push_to_buffers_with_ts(). However, only the low
3 bytes of each __le32 field are populated by the device data:

memcpy(&buffer.comp_press, &data->buf[3], 3);
memcpy(&buffer.comp_temp,  &data->buf[0], 3);

The high byte of each field is left uninitialised on the stack.
The bmp580 channels declare storagebits = 32, so the IIO core
transports all four bytes per sample to userspace as part of the
scan element, leaking two bytes of kernel stack per scan.

Zero-initialise the buffer before populating it, mirroring the fix
applied to bme280_trigger_handler() in commit 018f50909e66 ("iio:
bmp280: zero-init buffer").

Fixes: 872c8014e05e ("iio: pressure: bmp280: drop sensor_data array")
Cc: stable@vger.kernel.org
Signed-off-by: David Carlier <devnexen@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/iio/pressure/bmp280-core.c

index 9b489766e457a2614d183d6dbb74b09ef28451db..0ebe0b682caae5adbcb2a4a3b7df3f2d88f3d7d5 100644 (file)
@@ -1910,7 +1910,7 @@ static irqreturn_t bmp380_trigger_handler(int irq, void *p)
                u32 comp_press;
                s32 comp_temp;
                aligned_s64 timestamp;
-       } buffer;
+       } buffer = { };
        int ret;
 
        guard(mutex)(&data->lock);