linux/drivers/iio/magnetometer
Jonathan Cameron f817a9938e iio:magnetometer:mag3110: Fix alignment and data leak issues.
commit 89deb13342 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 but
does make the code slightly less fragile so I have included it.

Fixes: 39631b5f95 ("iio: Add Freescale mag3110 magnetometer driver")
Reported-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Cc: <Stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20200920112742.170751-4-jic23@kernel.org
[sudip: adjust context]
Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-01-09 13:43:48 +01: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_i2c.c
bmc150_magn_spi.c
bmc150_magn.c
bmc150_magn.h
hid-sensor-magn-3d.c
hmc5843_core.c
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
hmc5843.h
Kconfig
mag3110.c iio:magnetometer:mag3110: Fix alignment and data leak issues. 2021-01-09 13:43:48 +01:00
Makefile
mmc35240.c
st_magn_buffer.c iio:st_magn: Fix enable device after trigger 2018-12-05 19:32:13 +01:00
st_magn_core.c
st_magn_i2c.c
st_magn_spi.c
st_magn.h