linux/drivers/iio/magnetometer
Jonathan Cameron 176fb9423a iio:magnetometer:ak8975 Fix alignment and data leak issues.
commit 02ad21cefb 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:47:50 +02:00
..
Kconfig
Makefile
ak8974.c
ak8975.c iio:magnetometer:ak8975 Fix alignment and data leak issues. 2020-09-17 13:47:50 +02:00
bmc150_magn.c
bmc150_magn.h
bmc150_magn_i2c.c
bmc150_magn_spi.c
hid-sensor-magn-3d.c
hmc5843.h
hmc5843_core.c
hmc5843_i2c.c
hmc5843_spi.c
mag3110.c
mmc35240.c
rm3100-core.c
rm3100-i2c.c
rm3100-spi.c
rm3100.h
st_magn.h
st_magn_buffer.c
st_magn_core.c
st_magn_i2c.c
st_magn_spi.c