OpenCloudOS-Kernel/drivers/iio/imu/st_lsm6dsx
Jonathan Cameron c14edb4d0b iio:imu:st_lsm6dsx 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 an array of suitable structures in the iio_priv() data.

This data is allocated with kzalloc so no data can leak apart from
previous readings.

For the tagged path the data is aligned by using __aligned(8) for
the buffer on the stack.

There has been a lot of churn in this driver, so likely backports
may be needed for stable.

Fixes: 290a6ce11d ("iio: imu: add support to lsm6dsx driver")
Reported-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
Cc: <Stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20200722155103.979802-17-jic23@kernel.org
2020-09-21 20:01:51 +01:00
..
Kconfig iio: imu: st_lsm6dsx: add support to LSM6DSRX 2019-10-27 16:38:06 +00:00
Makefile iio: imu: st_lsm6dsx: add i3c basic support for LSM6DSO and LSM6DSR 2019-07-27 22:55:27 +01:00
st_lsm6dsx.h iio:imu:st_lsm6dsx Fix alignment and data leak issues 2020-09-21 20:01:51 +01:00
st_lsm6dsx_buffer.c iio:imu:st_lsm6dsx Fix alignment and data leak issues 2020-09-21 20:01:51 +01:00
st_lsm6dsx_core.c iio: imu: st_lsm6dsx: Scaling factor type set to IIO_VAL_INT_PLUS_NANO 2020-09-21 20:01:45 +01:00
st_lsm6dsx_i2c.c iio: st_lsm6dsx: Drop unneeded OF code 2019-12-29 15:20:04 +00:00
st_lsm6dsx_i3c.c iio: imu: st_lsm6dsx: add i3c basic support for LSM6DSO and LSM6DSR 2019-07-27 22:55:27 +01:00
st_lsm6dsx_shub.c iio:imu:st_lsm6dsx: check st_lsm6dsx_shub_read_output return 2020-09-21 20:01:50 +01:00
st_lsm6dsx_spi.c iio: st_lsm6dsx: Drop unneeded OF code 2019-12-29 15:20:04 +00:00