linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/16] IIO: Introduce iio_push_to_buffers_with_ts() taking an input buffer length argument.
@ 2025-03-09 18:20 Jonathan Cameron
  2025-03-09 18:20 ` [PATCH 01/16] iio: introduced iio_push_to_buffers_with_ts() that takes a total_len argument Jonathan Cameron
                   ` (15 more replies)
  0 siblings, 16 replies; 28+ messages in thread
From: Jonathan Cameron @ 2025-03-09 18:20 UTC (permalink / raw)
  To: linux-iio; +Cc: David Lechner, Nuno Sá, Jonathan Cameron

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

When using the IIO buffers, the length of each scan element is always known to
the IIO core (used for sizing kfifo elements etc) and depends on which channels
are enabled. Devices often use fixed size structures or arrays.

The core code previously had no way to check that the driver had provided a large
enough buffer, potentially leading to errors or to non sanitized data being presented
to userspace. In particular the iio_push_to_buffers_with_timestamp() helper
has the non obvious requirement for a larger buffer when timestamps are enabled
than that containing the rest of the channels (under the control of the driver).
This has lead to bugs in the past and this series aims to make that impossible
in the future by passing the size of the storage into a new variant of the helper
iio_push_to_buffers_with_ts() and performing a runtime check.

Once all drivers are converted, the expectation is the _with_timestamp()
version without this check will be removed.

The patches in this series use this helper for a large number of simple cases
and fix a few minor issues found during the conversion.  This does not cover
all drivers in each category, leaving more complex cases for future series.
Some of the remaining cases need substantial refactoring, others look to have
bugs that need more careful consideration than the cases in this series.

All comments welcome.  I haven't attempted to cc all the relevant driver
maintainers as that is a long list!

Jonathan Cameron (16):
  iio: introduced iio_push_to_buffers_with_ts() that takes a total_len
    argument.
  iio: dummy: Use a fixed structure to build up scan to push to buffers.
  iio: dummy: Switch to iio_push_to_buffers_with_ts() and provide size
    of storage
  iio: adc: ti-ads131e08: Use new iio_push_to_buffers_with_ts() to
    provide length sanity check.
  iio: adc: Use iio_push_to_buffers_with_ts() to provide length for
    runtime checks.
  iio: accel: Use iio_push_to_buffers_with_ts() to provide length for
    runtime checks.
  iio: accel: hid: Use iio_push_to_buffers_with_ts() to provide length
    for runtime checks.
  iio: chemical: Use iio_push_to_buffers_with_ts() to provide length for
    runtime checks.
  iio: temp: maxim-thermocouple: Fix potential lack of DMA safe buffer.
  iio: temperature: Use iio_push_to_buffers_with_ts() to provide length
    for runtime checks.
  iio: resolver: Use iio_push_to_buffers_with_ts() to provide length for
    runtime checks.
  iio: proximity: irsd200: Use a struct for scan and
    iio_push_to_buffers_with_ts()
  iio: proximity: Use iio_push_to_buffers_with_ts() to provide length
    for runtime checks.
  iio: pressure: zpa2326: Use aligned_s64 for the timestamp
  iio: pressure: Use iio_push_to_buffers_with_ts() to provide length for
    runtime checks.
  iio: magnetometer: Use iio_push_to_buffers_with_ts() to provide length
    for runtime checks.

 drivers/iio/accel/adxl355_core.c              |  4 +--
 drivers/iio/accel/bma180.c                    |  3 ++-
 drivers/iio/accel/bma220_spi.c                |  4 +--
 drivers/iio/accel/bma400_core.c               |  5 ++--
 drivers/iio/accel/fxls8962af-core.c           |  4 +--
 drivers/iio/accel/hid-sensor-accel-3d.c       |  2 +-
 drivers/iio/accel/kxcjk-1013.c                |  4 +--
 drivers/iio/accel/kxsd9.c                     |  5 ++--
 drivers/iio/accel/mma7455_core.c              |  5 ++--
 drivers/iio/accel/mma8452.c                   |  5 ++--
 drivers/iio/accel/msa311.c                    |  4 +--
 drivers/iio/accel/mxc4005.c                   |  4 +--
 drivers/iio/accel/sca3300.c                   |  5 ++--
 drivers/iio/accel/stk8312.c                   |  2 +-
 drivers/iio/accel/stk8ba50.c                  |  4 +--
 drivers/iio/adc/ad4000.c                      |  3 ++-
 drivers/iio/adc/ad4030.c                      |  5 ++--
 drivers/iio/adc/ad4695.c                      |  3 ++-
 drivers/iio/adc/ad7266.c                      |  5 ++--
 drivers/iio/adc/ad7298.c                      |  5 ++--
 drivers/iio/adc/ad7380.c                      |  5 ++--
 drivers/iio/adc/ad7476.c                      |  4 +--
 drivers/iio/adc/ad7606.c                      |  4 +--
 drivers/iio/adc/ad7768-1.c                    |  5 ++--
 drivers/iio/adc/ad7779.c                      |  3 ++-
 drivers/iio/adc/ad7923.c                      |  4 +--
 drivers/iio/adc/dln2-adc.c                    |  4 +--
 drivers/iio/adc/ina2xx-adc.c                  |  3 ++-
 drivers/iio/adc/max1118.c                     |  2 +-
 drivers/iio/adc/max11410.c                    |  4 +--
 drivers/iio/adc/max1363.c                     |  4 +--
 drivers/iio/adc/mcp3911.c                     |  4 +--
 drivers/iio/adc/mxs-lradc-adc.c               |  3 ++-
 drivers/iio/adc/pac1921.c                     |  3 ++-
 drivers/iio/adc/rockchip_saradc.c             |  3 ++-
 drivers/iio/adc/rtq6056.c                     |  3 ++-
 drivers/iio/adc/stm32-adc.c                   |  4 +--
 drivers/iio/adc/ti-adc081c.c                  |  4 +--
 drivers/iio/adc/ti-adc0832.c                  |  4 +--
 drivers/iio/adc/ti-adc084s021.c               |  4 +--
 drivers/iio/adc/ti-adc12138.c                 |  4 +--
 drivers/iio/adc/ti-ads1015.c                  |  4 +--
 drivers/iio/adc/ti-ads1119.c                  |  4 +--
 drivers/iio/adc/ti-ads124s08.c                |  4 +--
 drivers/iio/adc/ti-ads131e08.c                |  5 ++--
 drivers/iio/adc/ti-ads8688.c                  |  4 +--
 drivers/iio/adc/ti-lmp92064.c                 |  4 +--
 drivers/iio/adc/ti-tlc4541.c                  |  4 +--
 drivers/iio/adc/ti-tsc2046.c                  |  5 ++--
 drivers/iio/adc/vf610_adc.c                   |  7 +++---
 drivers/iio/chemical/atlas-sensor.c           |  5 ++--
 drivers/iio/chemical/bme680_core.c            |  4 +--
 drivers/iio/chemical/ccs811.c                 |  4 +--
 drivers/iio/chemical/ens160_core.c            |  4 +--
 drivers/iio/chemical/pms7003.c                |  5 ++--
 drivers/iio/chemical/scd30_core.c             |  3 ++-
 drivers/iio/chemical/scd4x.c                  |  3 ++-
 drivers/iio/chemical/sps30.c                  |  4 +--
 drivers/iio/dummy/iio_simple_dummy_buffer.c   | 18 ++++++-------
 drivers/iio/magnetometer/af8133j.c            |  3 ++-
 drivers/iio/magnetometer/ak8974.c             |  5 ++--
 drivers/iio/magnetometer/ak8975.c             |  4 +--
 drivers/iio/magnetometer/als31300.c           |  4 +--
 drivers/iio/magnetometer/bmc150_magn.c        |  4 +--
 drivers/iio/magnetometer/hmc5843.h            |  2 +-
 drivers/iio/magnetometer/hmc5843_core.c       |  4 +--
 drivers/iio/magnetometer/mag3110.c            |  4 +--
 drivers/iio/magnetometer/rm3100-core.c        |  4 +--
 drivers/iio/magnetometer/yamaha-yas530.c      |  5 ++--
 drivers/iio/pressure/bmp280-core.c            | 25 +++++++++++--------
 drivers/iio/pressure/hid-sensor-press.c       |  5 ++--
 drivers/iio/pressure/hsc030pa.c               |  4 +--
 drivers/iio/pressure/mpl3115.c                |  4 +--
 drivers/iio/pressure/rohm-bm1390.c            |  3 ++-
 drivers/iio/pressure/zpa2326.c                |  6 ++---
 drivers/iio/proximity/as3935.c                |  4 +--
 drivers/iio/proximity/hx9023s.c               |  4 +--
 drivers/iio/proximity/irsd200.c               | 12 ++++++---
 drivers/iio/proximity/mb1232.c                |  4 +--
 .../iio/proximity/pulsedlight-lidar-lite-v2.c |  5 ++--
 drivers/iio/proximity/srf08.c                 |  4 +--
 drivers/iio/proximity/sx_common.c             |  4 +--
 drivers/iio/proximity/vl53l0x-i2c.c           |  4 +--
 drivers/iio/resolver/ad2s1210.c               |  3 ++-
 .../iio/temperature/hid-sensor-temperature.c  |  5 ++--
 drivers/iio/temperature/maxim_thermocouple.c  |  7 +++---
 drivers/iio/temperature/tmp006.c              |  4 +--
 include/linux/iio/buffer.h                    | 13 ++++++++++
 88 files changed, 230 insertions(+), 179 deletions(-)

-- 
2.48.1


^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2025-04-06 17:15 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-09 18:20 [PATCH 00/16] IIO: Introduce iio_push_to_buffers_with_ts() taking an input buffer length argument Jonathan Cameron
2025-03-09 18:20 ` [PATCH 01/16] iio: introduced iio_push_to_buffers_with_ts() that takes a total_len argument Jonathan Cameron
2025-03-10  8:34   ` Nuno Sá
2025-03-10 20:04     ` Jonathan Cameron
2025-03-10 22:16       ` Nuno Sá
2025-03-09 18:20 ` [PATCH 02/16] iio: dummy: Use a fixed structure to build up scan to push to buffers Jonathan Cameron
2025-03-10 21:10   ` David Lechner
2025-03-09 18:20 ` [PATCH 03/16] iio: dummy: Switch to iio_push_to_buffers_with_ts() and provide size of storage Jonathan Cameron
2025-03-09 18:20 ` [PATCH 04/16] iio: adc: ti-ads131e08: Use new iio_push_to_buffers_with_ts() to provide length sanity check Jonathan Cameron
2025-03-10 22:07   ` David Lechner
2025-03-09 18:20 ` [PATCH 05/16] iio: adc: Use iio_push_to_buffers_with_ts() to provide length for runtime checks Jonathan Cameron
2025-03-10 21:49   ` David Lechner
2025-04-06 17:02     ` Jonathan Cameron
2025-04-06 17:15       ` David Lechner
2025-03-09 18:20 ` [PATCH 06/16] iio: accel: " Jonathan Cameron
2025-03-10 22:20   ` David Lechner
2025-04-06 17:07     ` Jonathan Cameron
2025-03-09 18:20 ` [PATCH 07/16] iio: accel: hid: " Jonathan Cameron
2025-03-11 18:30   ` David Lechner
2025-03-09 18:20 ` [PATCH 08/16] iio: chemical: " Jonathan Cameron
2025-03-09 18:20 ` [PATCH 09/16] iio: temp: maxim-thermocouple: Fix potential lack of DMA safe buffer Jonathan Cameron
2025-03-09 18:20 ` [PATCH 10/16] iio: temperature: Use iio_push_to_buffers_with_ts() to provide length for runtime checks Jonathan Cameron
2025-03-09 18:20 ` [PATCH 11/16] iio: resolver: " Jonathan Cameron
2025-03-09 18:20 ` [PATCH 12/16] iio: proximity: irsd200: Use a struct for scan and iio_push_to_buffers_with_ts() Jonathan Cameron
2025-03-09 18:20 ` [PATCH 13/16] iio: proximity: Use iio_push_to_buffers_with_ts() to provide length for runtime checks Jonathan Cameron
2025-03-09 18:20 ` [PATCH 14/16] iio: pressure: zpa2326: Use aligned_s64 for the timestamp Jonathan Cameron
2025-03-09 18:20 ` [PATCH 15/16] iio: pressure: Use iio_push_to_buffers_with_ts() to provide length for runtime checks Jonathan Cameron
2025-03-09 18:21 ` [PATCH 16/16] iio: magnetometer: " Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).