OpenCloudOS-Kernel/drivers/iio/accel
Jonathan Cameron 89226a296d iio:accel:mma8452: Fix timestamp alignment and prevent data leak.
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>
2020-08-22 11:38:48 +01:00
..
Kconfig iio: accel: bma400: add support for bma400 spi 2020-06-14 11:49:16 +01:00
Makefile iio: accel: bma400: add support for bma400 spi 2020-06-14 11:49:16 +01:00
adis16201.c iio: remove explicit IIO device parent assignment 2020-06-14 11:49:59 +01:00
adis16209.c iio: remove explicit IIO device parent assignment 2020-06-14 11:49:59 +01:00
adxl345.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 330 2019-06-05 17:37:06 +02:00
adxl345_core.c Replace HTTP links with HTTPS ones: drivers/iio 2020-07-13 15:05:59 +01:00
adxl345_i2c.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 330 2019-06-05 17:37:06 +02:00
adxl345_spi.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 330 2019-06-05 17:37:06 +02:00
adxl372.c iio: Move attach/detach of the poll func to the core 2020-06-20 17:34:44 +01:00
adxl372.h iio: adxl372: Add support for I2C communication 2018-09-08 15:54:38 +01:00
adxl372_i2c.c iio: adxl372: Add support for I2C communication 2018-09-08 15:54:38 +01:00
adxl372_spi.c iio: adxl372: declare missing of table 2019-04-27 13:57:36 +01:00
bma180.c iio: remove explicit IIO device parent assignment 2020-06-14 11:49:59 +01:00
bma220_spi.c iio: accel: bma220_spi: Do not define 'struct acpi_device_id' when !CONFIG_ACPI 2020-07-20 09:02:47 +01:00
bma400.h iio: accel: bma400: basic regulator support 2019-12-29 15:20:02 +00:00
bma400_core.c iio: remove explicit IIO device parent assignment 2020-06-14 11:49:59 +01:00
bma400_i2c.c iio: accel: Add driver for the BMA400 2019-12-29 15:20:02 +00:00
bma400_spi.c iio: accel: bma400: add support for bma400 spi 2020-06-14 11:49:16 +01:00
bmc150-accel-core.c iio: Move attach/detach of the poll func to the core 2020-06-20 17:34:44 +01:00
bmc150-accel-i2c.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 288 2019-06-05 17:36:37 +02:00
bmc150-accel-spi.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 13 2019-05-21 11:28:45 +02:00
bmc150-accel.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
cros_ec_accel_legacy.c iio: cros_ec_accel_legacy: Add Read Only frequency entries 2020-07-12 14:45:35 +01:00
da280.c iio: remove explicit IIO device parent assignment 2020-06-14 11:49:59 +01:00
da311.c iio: remove explicit IIO device parent assignment 2020-06-14 11:49:59 +01:00
dmard06.c iio: remove explicit IIO device parent assignment 2020-06-14 11:49:59 +01:00
dmard09.c iio: remove explicit IIO device parent assignment 2020-06-14 11:49:59 +01:00
dmard10.c iio: remove explicit IIO device parent assignment 2020-06-14 11:49:59 +01:00
hid-sensor-accel-3d.c iio: remove explicit IIO device parent assignment 2020-06-14 11:49:59 +01:00
kxcjk-1013.c iio: Move attach/detach of the poll func to the core 2020-06-20 17:34:44 +01:00
kxsd9-i2c.c iio: accel: kxsd9-i2c: Use mod_devicetable.h and drop of_match_ptr macro 2020-04-25 15:31:34 +01:00
kxsd9-spi.c Merge 5.2-rc3 into staging-next 2019-06-03 07:27:16 +02:00
kxsd9.c iio: accel: kxsd9: Fix alignment of local buffer. 2020-08-22 11:38:47 +01:00
kxsd9.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
mc3230.c iio: remove explicit IIO device parent assignment 2020-06-14 11:49:59 +01:00
mma7455.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
mma7455_core.c iio: remove explicit IIO device parent assignment 2020-06-14 11:49:59 +01:00
mma7455_i2c.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
mma7455_spi.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
mma7660.c iio: remove explicit IIO device parent assignment 2020-06-14 11:49:59 +01:00
mma8452.c iio:accel:mma8452: Fix timestamp alignment and prevent data leak. 2020-08-22 11:38:48 +01:00
mma9551.c iio: remove explicit IIO device parent assignment 2020-06-14 11:49:59 +01:00
mma9551_core.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 288 2019-06-05 17:36:37 +02:00
mma9551_core.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 288 2019-06-05 17:36:37 +02:00
mma9553.c iio: remove left-over parent assignments 2020-06-14 11:50:04 +01:00
mxc4005.c iio: remove explicit IIO device parent assignment 2020-06-14 11:49:59 +01:00
mxc6255.c iio: remove explicit IIO device parent assignment 2020-06-14 11:49:59 +01:00
sca3000.c iio: accel: sca3000: Fix 2 misspellings and demote nonconforming kerneldocs 2020-07-20 09:03:24 +01:00
ssp_accel_sensor.c iio: Remove superfluous of_node assignments 2020-06-14 14:20:08 +01:00
st_accel.h iio: accel: st_sensors: add support for LIS2HH12 2020-04-19 16:56:30 +01:00
st_accel_buffer.c iio: Move attach/detach of the poll func to the core 2020-06-20 17:34:44 +01:00
st_accel_core.c iio: accel: st_sensors: add support for LIS2HH12 2020-04-19 16:56:30 +01:00
st_accel_i2c.c First set of new IIO device support, features and cleanup for the 5.8 cycle 2020-04-23 11:06:48 +02:00
st_accel_spi.c iio: st_sensors: Make use of device properties 2020-01-13 21:53:39 +00:00
stk8ba50.c iio: Move attach/detach of the poll func to the core 2020-06-20 17:34:44 +01:00
stk8312.c iio: Move attach/detach of the poll func to the core 2020-06-20 17:34:44 +01:00