linux/drivers/iio/imu
Jonathan Cameron 7b6b51234d iio:imu:bmi160: Fix alignment and data leak issues
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 array in the iio_priv() data with alignment
explicitly requested.  This data is allocated with kzalloc() so no
data can leak apart from previous readings.

In this driver, depending on which channels are enabled, the timestamp
can be in a number of locations.  Hence we cannot use a structure
to specify the data layout without it being misleading.

Fixes: 77c4ad2d6a ("iio: imu: Add initial support for Bosch BMI160")
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: Daniel Baluta  <daniel.baluta@gmail.com>
Cc: Daniel Baluta <daniel.baluta@oss.nxp.com>
Cc: <Stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20200920112742.170751-6-jic23@kernel.org
2020-12-03 19:40:28 +00:00
..
bmi160 iio:imu:bmi160: Fix alignment and data leak issues 2020-12-03 19:40:28 +00:00
inv_icm42600 iio: imu: inv_icm42600: add accurate timestamping 2020-06-27 14:24:42 +01:00
inv_mpu6050 iio:imu:inv_mpu6050: Use regmap_noinc_read for fifo reads. 2020-09-21 20:01:51 +01:00
st_lsm6dsx iio: imu: st_lsm6dsx: add support to LSM6DSOP 2020-12-03 19:40:24 +00:00
adis16400.c iio: adis16400: Drop adis_burst usage 2020-09-21 20:01:45 +01:00
adis16460.c iio: adis16460: Use Managed device functions 2020-09-16 19:06:09 +01:00
adis16475.c iio: adis16475: Drop adis_burst usage 2020-09-21 20:01:45 +01:00
adis16480.c iio: adis16480: Use Managed device functions 2020-09-16 19:06:09 +01:00
adis_buffer.c iio: adis: Move burst mode into adis_data 2020-09-21 20:01:45 +01:00
adis_trigger.c iio: adis: Drop non Managed device functions 2020-09-16 19:06:10 +01:00
adis.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
fxos8700_core.c iio: remove explicit IIO device parent assignment 2020-06-14 11:49:59 +01:00
fxos8700_i2c.c iio: imu: Add support for the FXOS8700 IMU 2019-10-22 10:24:50 +01:00
fxos8700_spi.c iio: imu: Add support for the FXOS8700 IMU 2019-10-22 10:24:50 +01:00
fxos8700.h iio: imu: Add support for the FXOS8700 IMU 2019-10-22 10:24:50 +01:00
Kconfig iio: imu: add Kconfig and Makefile for inv_icm42600 driver 2020-06-27 14:20:25 +01:00
kmx61.c iio:trigger: rename try_reenable() to reenable() plus return void 2020-12-03 19:40:26 +00:00
Makefile iio: imu: add Kconfig and Makefile for inv_icm42600 driver 2020-06-27 14:20:25 +01:00