kernel-fxtec-pro1x/drivers/iio/accel
Jonathan Cameron 3cb4aa0027 iio:accel:mma8452: Fix timestamp alignment and prevent data leak.
commit 89226a296d816727405d3fea684ef69e7d388bd8 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 a 16 byte u8 array 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 with alignment
ensured by use of an explicit c structure.  This data is allocated
with kzalloc so no data can leak appart from previous readings.

The additional forcing of the 8 byte alignment of the timestamp
is not strictly necessary but makes the code less fragile by
making this explicit.

Fixes: c7eeea93ac ("iio: Add Freescale MMA8452Q 3-axis accelerometer driver")
Reported-by: Lars-Peter Clausen <lars@metafoo.de>
Cc: Peter Meerwald <pmeerw@pmeerw.net>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-09-17 13:45:28 +02:00
..
adis16201.c
adis16209.c
adxl345.h
adxl345_core.c
adxl345_i2c.c
adxl345_spi.c
bma180.c
bma220_spi.c
bmc150-accel-core.c iio:accel:bmc150-accel: Fix timestamp alignment and prevent data leak. 2020-09-17 13:45:27 +02:00
bmc150-accel-i2c.c
bmc150-accel-spi.c
bmc150-accel.h
cros_ec_accel_legacy.c iio: cros_ec_accel_legacy: Fix incorrect channel setting 2019-08-16 10:12:37 +02:00
da280.c
da311.c
dmard06.c
dmard09.c
dmard10.c
hid-sensor-accel-3d.c
Kconfig
kxcjk-1013.c io: accel: kxcjk1013: restore the range after resume. 2019-04-27 09:36:35 +02:00
kxsd9-i2c.c
kxsd9-spi.c
kxsd9.c iio: accel: kxsd9: Fix alignment of local buffer. 2020-09-17 13:45:28 +02:00
kxsd9.h
Makefile
mc3230.c
mma7455.h
mma7455_core.c iio:accel:mma7455: Fix timestamp alignment and prevent data leak. 2020-09-17 13:45:28 +02:00
mma7455_i2c.c
mma7455_spi.c
mma7660.c
mma8452.c iio:accel:mma8452: Fix timestamp alignment and prevent data leak. 2020-09-17 13:45:28 +02:00
mma9551.c
mma9551_core.c
mma9551_core.h
mma9553.c
mxc4005.c
mxc6255.c
sca3000.c iio: sca3000: Remove an erroneous 'get_device()' 2020-05-27 17:37:42 +02:00
ssp_accel_sensor.c
st_accel.h
st_accel_buffer.c
st_accel_core.c
st_accel_i2c.c iio: st_sensors: remap SMO8840 to LIS2DH12 2020-03-25 08:06:10 +01:00
st_accel_spi.c
stk8ba50.c
stk8312.c