linux-stable/drivers/iio
Jonathan Cameron eacd48c729 iio:accel:mma8452: Fix timestamp alignment and prevent data leak.
commit 89226a296d 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-23 10:46:29 +02:00
..
accel iio:accel:mma8452: Fix timestamp alignment and prevent data leak. 2020-09-23 10:46:29 +02:00
adc iio:adc:ti-adc081c Fix alignment and data leak issues 2020-09-23 10:46:29 +02:00
amplifiers
buffer iio:kfifo_buf: check for uint overflow 2018-06-05 11:41:58 +02:00
chemical iio:chemical:ccs811: Fix timestamp alignment and prevent data leak. 2020-09-23 10:46:29 +02:00
common iio: common: ssp_sensors: Initialize calculated_time in ssp_common_process_data 2019-05-31 06:47:29 -07:00
counter iio: 104-quad-8: Fix off-by-one error in register selection 2018-10-03 17:00:53 -07:00
dac iio: dac: ad5592r: fix unbalanced mutex unlocks in ad5592r_read_raw() 2020-08-21 09:48:17 +02:00
dummy
frequency iio: ad9523: Fix return value for ad952x_store() 2018-09-09 19:55:56 +02:00
gyro iio/gyro/bmg160: Use millidegrees for temperature scale 2019-04-27 09:35:35 +02:00
health iio:health:afe4404 Fix timestamp alignment and prevent data leak. 2020-07-22 09:22:24 +02:00
humidity iio:humidity:hdc100x Fix alignment and data leak issues 2020-07-22 09:22:22 +02:00
imu iio: imu: adis16400: fix memory leak 2020-08-05 10:06:48 +02:00
light iio:light:max44000 Fix timestamp alignment and prevent data leak. 2020-09-23 10:46:29 +02:00
magnetometer iio:magnetometer:ak8975 Fix alignment and data leak issues. 2020-09-23 10:46:29 +02:00
multiplexer
orientation iio/hid-sensors: Fix IIO_CHAN_INFO_RAW returning wrong values for signed numbers 2018-12-17 09:28:49 +01:00
potentiometer
potentiostat
pressure iio:pressure:ms5611 Fix buffer element alignment 2020-07-22 09:22:22 +02:00
proximity iio: srf04: fix wrong limitation in distance measuring 2019-11-12 19:18:08 +01:00
temperature iio/hid-sensors: Fix IIO_CHAN_INFO_RAW returning wrong values for signed numbers 2018-12-17 09:28:49 +01:00
trigger iio: trigger: stm32-timer: disable master mode when stopping 2020-04-02 16:34:17 +02:00
iio_core.h
iio_core_trigger.h
industrialio-buffer.c iio: buffer: align the size of scan bytes to size of the largest element 2020-01-23 08:20:30 +01:00
industrialio-configfs.c
industrialio-core.c iio: core: fix a possible circular locking dependency 2019-04-27 09:35:36 +02:00
industrialio-event.c
industrialio-sw-device.c
industrialio-sw-trigger.c
industrialio-trigger.c
industrialio-triggered-event.c
inkern.c
Kconfig
Makefile