From: Matti Vaittinen <mazziesaccount@gmail.com> To: Matti Vaittinen <mazziesaccount@gmail.com>, Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com> Cc: "Lars-Peter Clausen" <lars@metafoo.de>, "Michael Hennerich" <Michael.Hennerich@analog.com>, "Cosmin Tanislav" <cosmin.tanislav@analog.com>, "Jonathan Cameron" <jic23@kernel.org>, "Eugen Hristev" <eugen.hristev@microchip.com>, "Nicolas Ferre" <nicolas.ferre@microchip.com>, "Alexandre Belloni" <alexandre.belloni@bootlin.com>, "Claudiu Beznea" <claudiu.beznea@microchip.com>, "Benson Leung" <bleung@chromium.org>, "Guenter Roeck" <groeck@chromium.org>, "Matti Vaittinen" <mazziesaccount@gmail.com>, "Alexandru Ardelean" <alexandru.ardelean@analog.com>, "Miquel Raynal" <miquel.raynal@bootlin.com>, "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>, "Miaoqian Lin" <linmq006@gmail.com>, "Paul Cercueil" <paul@crapouillou.net>, "Mihail Chindris" <mihail.chindris@analog.com>, "Gwendal Grignou" <gwendal@chromium.org>, "Douglas Anderson" <dianders@chromium.org>, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, chrome-platform@lists.linux.dev Subject: [PATCH v3 00/10] iio: Fix unsafe buffer attributes Date: Mon, 3 Oct 2022 11:09:51 +0300 [thread overview] Message-ID: <cover.1664782676.git.mazziesaccount@gmail.com> (raw) [-- Attachment #1: Type: text/plain, Size: 3930 bytes --] IIO The iio_triggered_buffer_setup_ext() has been changed to expect that all attributes given in buffer_attrs array are device-attributes. This expectation has not been forced by the API and not all existing users were checked. Some drivers do register attributes created by IIO_CONST_ATTR(). The added attribute "wrapping" does not copy the pointer to stored string constant and when the sysfs file is read the kernel will access to invalid address. First 4 patches in the series aim to address both the drivers using IIO_CONST_ATTR(). These patches should be backportable. Please note that these patches have not been tested in the HW so testing/reviewing is highly appreciated. Following 4 (patches 5 ... 9) contain a minor simplification adding a macro for omitting open-coding of dummy attribute show functions. I am not super happy about the new macro IIO_STATIC_CONST_DEVICE_ATTR() which unconditionally creates a static function and a static struct iio_dev_attr. OTOH, I do believe static function + static struct iio_dev_attr should be the right thing to do for majority of use cases. The last patch in the series (patch 10) aims to change the function signatures so that similar issues would be avoided in the future. Here we also change the struct iio_buffer to have array of pointers to iio_dev_attr in order to avoid yet another copying in side the iio_triggered_buffer_setup_ext(). This change appeared to be somewhat intrusive - and as I lack the hardware to do thorough testing I added the request for testing tag here. Especially testing of adi-axi-adc would be highly appreciated as it is using the industrialio-buffer-dmaengine. Changelog v3: - Split the series to allow easier backport and review. This also allows merging the smaller fixes with less of a risk for crashing and burning everything :) Changelog v2: - fix also the cros_ec_sensors_core.c - fix also the industrialio-buffer-dmaengine.c - add RFT + this cover-letter. -- Matti Vaittinen (10): iio: adxl367: Fix unsafe buffer attributes iio: adxl372: Fix unsafe buffer attributes iio: bmc150-accel-core: Fix unsafe buffer attributes iio: at91-sama5d2_adc: Fix unsafe buffer attributes iio: Add IIO_STATIC_CONST_DEVICE_ATTR iio: adxl367: Use IIO_STATIC_CONST_DEVICE_ATTR() iio: adxl372: Use IIO_STATIC_CONST_DEVICE_ATTR() iio: bmc150-accel-core: Use IIO_STATIC_CONST_DEVICE_ATTR() iio: at91-sama5d2_adc: Use IIO_STATIC_CONST_DEVICE_ATTR() iio: Don't silently expect attribute types drivers/iio/accel/adxl367.c | 16 ++++++++-------- drivers/iio/accel/adxl372.c | 16 ++++++++-------- drivers/iio/accel/bmc150-accel-core.c | 18 +++++++++--------- drivers/iio/adc/at91-sama5d2_adc.c | 16 ++++++++-------- .../iio/buffer/industrialio-buffer-dmaengine.c | 4 ++-- .../iio/buffer/industrialio-triggered-buffer.c | 4 ++-- drivers/iio/buffer/kfifo_buf.c | 2 +- .../cros_ec_sensors/cros_ec_sensors_core.c | 6 +++--- .../common/hid-sensors/hid-sensor-trigger.c | 8 ++++---- drivers/iio/industrialio-buffer.c | 11 +++++++---- include/linux/iio/buffer_impl.h | 2 +- include/linux/iio/kfifo_buf.h | 3 ++- include/linux/iio/sysfs.h | 11 +++++++++++ include/linux/iio/triggered_buffer.h | 6 +++--- 14 files changed, 69 insertions(+), 54 deletions(-) base-commit: f76349cf41451c5c42a99f18a9163377e4b364ff -- 2.37.3 -- Matti Vaittinen, Linux device drivers ROHM Semiconductors, Finland SWDC Kiviharjunlenkki 1E 90220 OULU FINLAND ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~ Simon says - in Latin please. ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~ Thanks to Simon Glass for the translation =] [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --]
WARNING: multiple messages have this Message-ID (diff)
From: Matti Vaittinen <mazziesaccount@gmail.com> To: Matti Vaittinen <mazziesaccount@gmail.com>, Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com> Cc: "Gwendal Grignou" <gwendal@chromium.org>, "Douglas Anderson" <dianders@chromium.org>, linux-iio@vger.kernel.org, "Alexandre Belloni" <alexandre.belloni@bootlin.com>, "Paul Cercueil" <paul@crapouillou.net>, "Miquel Raynal" <miquel.raynal@bootlin.com>, "Guenter Roeck" <groeck@chromium.org>, chrome-platform@lists.linux.dev, "Lars-Peter Clausen" <lars@metafoo.de>, "Miaoqian Lin" <linmq006@gmail.com>, "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>, "Alexandru Ardelean" <alexandru.ardelean@analog.com>, "Mihail Chindris" <mihail.chindris@analog.com>, "Michael Hennerich" <Michael.Hennerich@analog.com>, "Matti Vaittinen" <mazziesaccount@gmail.com>, "Cosmin Tanislav" <cosmin.tanislav@analog.com>, "Benson Leung" <bleung@chromium.org>, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, "Eugen Hristev" <eugen.hristev@microchip.com>, "Claudiu Beznea" <claudiu.beznea@microchip.com>, "Jonathan Cameron" <jic23@kernel.org> Subject: [PATCH v3 00/10] iio: Fix unsafe buffer attributes Date: Mon, 3 Oct 2022 11:09:51 +0300 [thread overview] Message-ID: <cover.1664782676.git.mazziesaccount@gmail.com> (raw) [-- Attachment #1.1: Type: text/plain, Size: 3930 bytes --] IIO The iio_triggered_buffer_setup_ext() has been changed to expect that all attributes given in buffer_attrs array are device-attributes. This expectation has not been forced by the API and not all existing users were checked. Some drivers do register attributes created by IIO_CONST_ATTR(). The added attribute "wrapping" does not copy the pointer to stored string constant and when the sysfs file is read the kernel will access to invalid address. First 4 patches in the series aim to address both the drivers using IIO_CONST_ATTR(). These patches should be backportable. Please note that these patches have not been tested in the HW so testing/reviewing is highly appreciated. Following 4 (patches 5 ... 9) contain a minor simplification adding a macro for omitting open-coding of dummy attribute show functions. I am not super happy about the new macro IIO_STATIC_CONST_DEVICE_ATTR() which unconditionally creates a static function and a static struct iio_dev_attr. OTOH, I do believe static function + static struct iio_dev_attr should be the right thing to do for majority of use cases. The last patch in the series (patch 10) aims to change the function signatures so that similar issues would be avoided in the future. Here we also change the struct iio_buffer to have array of pointers to iio_dev_attr in order to avoid yet another copying in side the iio_triggered_buffer_setup_ext(). This change appeared to be somewhat intrusive - and as I lack the hardware to do thorough testing I added the request for testing tag here. Especially testing of adi-axi-adc would be highly appreciated as it is using the industrialio-buffer-dmaengine. Changelog v3: - Split the series to allow easier backport and review. This also allows merging the smaller fixes with less of a risk for crashing and burning everything :) Changelog v2: - fix also the cros_ec_sensors_core.c - fix also the industrialio-buffer-dmaengine.c - add RFT + this cover-letter. -- Matti Vaittinen (10): iio: adxl367: Fix unsafe buffer attributes iio: adxl372: Fix unsafe buffer attributes iio: bmc150-accel-core: Fix unsafe buffer attributes iio: at91-sama5d2_adc: Fix unsafe buffer attributes iio: Add IIO_STATIC_CONST_DEVICE_ATTR iio: adxl367: Use IIO_STATIC_CONST_DEVICE_ATTR() iio: adxl372: Use IIO_STATIC_CONST_DEVICE_ATTR() iio: bmc150-accel-core: Use IIO_STATIC_CONST_DEVICE_ATTR() iio: at91-sama5d2_adc: Use IIO_STATIC_CONST_DEVICE_ATTR() iio: Don't silently expect attribute types drivers/iio/accel/adxl367.c | 16 ++++++++-------- drivers/iio/accel/adxl372.c | 16 ++++++++-------- drivers/iio/accel/bmc150-accel-core.c | 18 +++++++++--------- drivers/iio/adc/at91-sama5d2_adc.c | 16 ++++++++-------- .../iio/buffer/industrialio-buffer-dmaengine.c | 4 ++-- .../iio/buffer/industrialio-triggered-buffer.c | 4 ++-- drivers/iio/buffer/kfifo_buf.c | 2 +- .../cros_ec_sensors/cros_ec_sensors_core.c | 6 +++--- .../common/hid-sensors/hid-sensor-trigger.c | 8 ++++---- drivers/iio/industrialio-buffer.c | 11 +++++++---- include/linux/iio/buffer_impl.h | 2 +- include/linux/iio/kfifo_buf.h | 3 ++- include/linux/iio/sysfs.h | 11 +++++++++++ include/linux/iio/triggered_buffer.h | 6 +++--- 14 files changed, 69 insertions(+), 54 deletions(-) base-commit: f76349cf41451c5c42a99f18a9163377e4b364ff -- 2.37.3 -- Matti Vaittinen, Linux device drivers ROHM Semiconductors, Finland SWDC Kiviharjunlenkki 1E 90220 OULU FINLAND ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~ Simon says - in Latin please. ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~ Thanks to Simon Glass for the translation =] [-- Attachment #1.2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --] [-- Attachment #2: Type: text/plain, Size: 176 bytes --] _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next reply other threads:[~2022-10-03 8:10 UTC|newest] Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-10-03 8:09 Matti Vaittinen [this message] 2022-10-03 8:09 ` [PATCH v3 00/10] iio: Fix unsafe buffer attributes Matti Vaittinen 2022-10-03 8:10 ` [PATCH v3 01/10] iio: adxl367: " Matti Vaittinen 2022-10-16 11:12 ` Jonathan Cameron 2022-10-03 8:10 ` [PATCH v3 02/10] iio: adxl372: " Matti Vaittinen 2022-10-16 11:12 ` Jonathan Cameron 2022-10-03 8:11 ` [PATCH v3 03/10] iio: bmc150-accel-core: " Matti Vaittinen 2022-10-16 11:13 ` Jonathan Cameron 2022-10-03 8:11 ` [PATCH v3 04/10] iio: at91-sama5d2_adc: " Matti Vaittinen 2022-10-03 8:11 ` Matti Vaittinen 2022-10-06 8:34 ` Claudiu.Beznea 2022-10-06 8:34 ` Claudiu.Beznea 2022-10-16 11:14 ` Jonathan Cameron 2022-10-16 11:14 ` Jonathan Cameron 2022-10-03 8:12 ` [PATCH v3 05/10] iio: Add IIO_STATIC_CONST_DEVICE_ATTR Matti Vaittinen 2022-10-03 8:12 ` [PATCH v3 06/10] iio: adxl367: Use IIO_STATIC_CONST_DEVICE_ATTR() Matti Vaittinen 2022-10-03 8:12 ` [PATCH v3 07/10] iio: adxl372: " Matti Vaittinen 2022-10-03 8:13 ` [PATCH v3 08/10] iio: bmc150-accel-core: " Matti Vaittinen 2022-10-03 8:13 ` [PATCH v3 09/10] iio: at91-sama5d2_adc: " Matti Vaittinen 2022-10-03 8:13 ` Matti Vaittinen 2022-10-06 8:35 ` Claudiu.Beznea 2022-10-06 8:35 ` Claudiu.Beznea 2022-10-03 8:13 ` [RFT PATCH v3 10/10] iio: Don't silently expect attribute types Matti Vaittinen 2022-10-03 8:13 ` Matti Vaittinen 2022-10-03 8:43 ` Andy Shevchenko 2022-10-03 8:43 ` Andy Shevchenko 2022-10-03 8:58 ` Matti Vaittinen 2022-10-03 8:58 ` Matti Vaittinen 2022-10-03 9:02 ` Matti Vaittinen 2022-10-03 9:02 ` Matti Vaittinen 2022-10-03 9:39 ` Andy Shevchenko 2022-10-03 9:39 ` Andy Shevchenko 2022-10-03 9:42 ` Andy Shevchenko 2022-10-03 9:42 ` Andy Shevchenko 2022-10-06 8:35 ` Claudiu.Beznea 2022-10-06 8:35 ` Claudiu.Beznea 2022-10-06 12:53 ` Matti Vaittinen 2022-10-06 12:53 ` Matti Vaittinen 2022-10-09 17:38 ` Jonathan Cameron 2022-10-09 17:38 ` Jonathan Cameron 2022-10-10 9:36 ` Matti Vaittinen 2022-10-10 9:36 ` Matti Vaittinen 2022-11-05 14:45 ` Jonathan Cameron 2022-11-05 14:45 ` Jonathan Cameron
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=cover.1664782676.git.mazziesaccount@gmail.com \ --to=mazziesaccount@gmail.com \ --cc=Michael.Hennerich@analog.com \ --cc=alexandre.belloni@bootlin.com \ --cc=alexandru.ardelean@analog.com \ --cc=bleung@chromium.org \ --cc=chrome-platform@lists.linux.dev \ --cc=claudiu.beznea@microchip.com \ --cc=cosmin.tanislav@analog.com \ --cc=dianders@chromium.org \ --cc=eugen.hristev@microchip.com \ --cc=groeck@chromium.org \ --cc=gwendal@chromium.org \ --cc=jic23@kernel.org \ --cc=lars@metafoo.de \ --cc=linmq006@gmail.com \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-iio@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=matti.vaittinen@fi.rohmeurope.com \ --cc=mihail.chindris@analog.com \ --cc=miquel.raynal@bootlin.com \ --cc=nicolas.ferre@microchip.com \ --cc=paul@crapouillou.net \ --cc=u.kleine-koenig@pengutronix.de \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.