kernel-fxtec-pro1x/drivers/iio/magnetometer
Jonathan Cameron a24fd33527 iio:magnetometer:ak8975 Fix alignment and data leak issues.
commit 02ad21cefbac4d89ac443866f25b90449527737b 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 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 structure in the iio_priv() data.

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

The explicit alignment of ts is not necessary in this case as by
coincidence the padding will end up the same, however I consider
it to make the code less fragile and have included it.

Fixes: bc11ca4a0b ("iio:magnetometer:ak8975: triggered buffer support")
Reported-by: Lars-Peter Clausen <lars@metafoo.de>
Cc: Gregor Boirie <gregor.boirie@parrot.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
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:27 +02:00
..
ak8974.c iio: magnetometer: ak8974: Fix runtime PM imbalance on error 2020-07-22 09:32:02 +02:00
ak8975.c iio:magnetometer:ak8975 Fix alignment and data leak issues. 2020-09-17 13:45:27 +02:00
bmc150_magn.c iio:magnetometer: drop assign iio_info.driver_module and iio_trigger_ops.owner 2017-08-22 21:32:52 +01:00
bmc150_magn.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
bmc150_magn_i2c.c iio: magnetometer: bmc150_magn_i2c: Add OF device ID table 2017-03-19 10:50:10 +00:00
bmc150_magn_spi.c
hid-sensor-magn-3d.c iio/hid-sensors: Fix IIO_CHAN_INFO_RAW returning wrong values for signed numbers 2018-12-05 19:32:13 +01:00
hmc5843.h
hmc5843_core.c iio:magnetometer: drop assign iio_info.driver_module and iio_trigger_ops.owner 2017-08-22 21:32:52 +01:00
hmc5843_i2c.c iio: hmc5843: fix potential NULL pointer dereferences 2019-05-31 06:46:25 -07:00
hmc5843_spi.c iio: hmc5843: fix potential NULL pointer dereferences 2019-05-31 06:46:25 -07:00
Kconfig iio: magnetometer: ak8974: support AMI306 variant 2017-08-20 11:18:33 +01:00
mag3110.c iio: magnetometer: mag3110: Add ability to run in continuous mode 2018-05-12 11:01:59 +01:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
mmc35240.c iio:magnetometer: drop assign iio_info.driver_module and iio_trigger_ops.owner 2017-08-22 21:32:52 +01:00
st_magn.h iio: magnetometer: add support to LIS2MDL 2017-08-17 15:51:39 +01:00
st_magn_buffer.c iio:st_magn: Fix enable device after trigger 2018-12-05 19:32:13 +01:00
st_magn_core.c iio: magnetometer: st_magn: add SPI-3wire support to LIS3MDL 2017-10-10 20:36:33 +01:00
st_magn_i2c.c iio: magnetometer: add support to LIS2MDL 2017-08-17 15:51:39 +01:00
st_magn_spi.c iio: magnetometer: add support to LIS2MDL 2017-08-17 15:51:39 +01:00