linux/drivers/iio
Jonathan Cameron f817a9938e iio:magnetometer:mag3110: Fix alignment and data leak issues.
commit 89deb13342 upstream

One of a class of bugs pointed out by Lars in a recent review.
iio_push_to_buffers_with_timestamp() assumes the buffer used is aligned
to the size of the timestamp (8 bytes).  This is not guaranteed in
this driver which uses an array of smaller elements on the stack.
As Lars also noted this anti pattern can involve a leak of data to
userspace and that indeed can happen here.  We close both issues by
moving to a suitable structure in the iio_priv() data.
This data is allocated with kzalloc() so no data can leak apart from
previous readings.

The explicit alignment of ts is not necessary in this case but
does make the code slightly less fragile so I have included it.

Fixes: 39631b5f95 ("iio: Add Freescale mag3110 magnetometer driver")
Reported-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Cc: <Stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20200920112742.170751-4-jic23@kernel.org
[sudip: adjust context]
Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-01-09 13:43:48 +01:00
..
accel iio: accel: kxcjk1013: Add support for KIOX010A ACPI DSM for setting tablet-mode 2020-11-24 13:27:25 +01:00
adc iio: adc: rockchip_saradc: fix missing clk_disable_unprepare() on error in rockchip_saradc_resume 2020-12-30 11:26:15 +01:00
afe
amplifiers
buffer
chemical iio:chemical:ccs811: Fix timestamp alignment and prevent data leak. 2020-09-17 13:45:28 +02:00
common iio: st_sensors: rely on odr mask to know if odr can be set 2020-04-29 16:31:24 +02:00
counter
dac iio: dac: ad5592r: fix unbalanced mutex unlocks in ad5592r_read_raw() 2020-08-21 11:05:31 +02:00
dummy
frequency
gyro iio:gyro:itg3200: Fix timestamp alignment and prevent data leak. 2020-11-05 11:08:51 +01:00
health iio:health:afe4404 Fix timestamp alignment and prevent data leak. 2020-07-22 09:32:05 +02:00
humidity iio:humidity:hts221 Fix alignment and data leak issues 2020-07-22 09:32:02 +02:00
imu iio:imu:bmi160: Fix alignment and data leak issues 2021-01-09 13:43:48 +01:00
light iio:light:st_uvis25: Fix timestamp alignment and prevent data leak. 2020-12-30 11:26:15 +01:00
magnetometer iio:magnetometer:mag3110: Fix alignment and data leak issues. 2021-01-09 13:43:48 +01:00
multiplexer
orientation
potentiometer
potentiostat
pressure iio:pressure:mpl3115: Force alignment of buffer 2020-12-30 11:26:16 +01:00
proximity iio: srf04: fix wrong limitation in distance measuring 2019-11-12 19:20:40 +01:00
resolver
temperature iio: temperature: mlx90632 Relax the compatibility check 2019-06-25 11:35:54 +08:00
trigger iio: trigger: stm32-timer: disable master mode when stopping 2020-03-25 08:06:10 +01:00
iio_core_trigger.h
iio_core.h
industrialio-buffer.c iio: buffer: Fix demux update 2020-12-30 11:26:15 +01:00
industrialio-configfs.c
industrialio-core.c iio: core: fix a possible circular locking dependency 2019-04-27 09:36:35 +02:00
industrialio-event.c
industrialio-sw-device.c
industrialio-sw-trigger.c
industrialio-trigger.c
industrialio-triggered-event.c
inkern.c
Kconfig
Makefile