All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matti Vaittinen <mazziesaccount@gmail.com>
To: Jonathan Cameron <jic23@kernel.org>
Cc: "Matti Vaittinen" <matti.vaittinen@fi.rohmeurope.com>,
	"Cosmin Tanislav" <cosmin.tanislav@analog.com>,
	"Lars-Peter Clausen" <lars@metafoo.de>,
	"Michael Hennerich" <Michael.Hennerich@analog.com>,
	"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>,
	"Alexandru Ardelean" <alexandru.ardelean@analog.com>,
	"Srinivas Pandruvada" <srinivas.pandruvada@linux.intel.com>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Nathan Chancellor" <nathan@kernel.org>,
	"Miquel Raynal" <miquel.raynal@bootlin.com>,
	"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: Re: [RFT PATCH v2 2/2] iio: Fix unsafe buffer attributes
Date: Sun, 2 Oct 2022 17:25:48 +0300	[thread overview]
Message-ID: <3ebe3c45-e951-678b-ea55-89c5bf62e8bc@gmail.com> (raw)
In-Reply-To: <20221002145644.16db3aec@jic23-huawei>

On 10/2/22 16:57, Jonathan Cameron wrote:
> On Sat, 1 Oct 2022 10:44:23 +0300
> Matti Vaittinen <mazziesaccount@gmail.com> wrote:
> 
>> The iio_triggered_buffer_setup_ext() was changed by
>> commit 15097c7a1adc ("iio: buffer: wrap all buffer attributes into iio_dev_attr")
>> to silently expect that all attributes given in buffer_attrs array are
>> device-attributes. This expectation was not forced by the API - and some
>> drivers did 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 location.
>>
>> Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
>> Fixes: 15097c7a1adc ("iio: buffer: wrap all buffer attributes into iio_dev_attr")
> 
> Hi Matti,
> 
> This feels like we are doing too much in one go.
> I would start with fixes for each individual driver, then once those are in we
> come around again and do the refactor.
> 
> So for the first patch set (one per driver) just siwtch to yor new
> dev_attr but still use a struct attribute * array.
> Second series then does the refactor so we don't introduce any new instances
> in future. More churn but the code to backport is more tightly confined.

Agreed. Besides, backporting the fix to stable will be much easier that 
way. I'll split this for v3. Thanks for the input!


Yours,
	--Matti

-- 
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland

~~ When things go utterly wrong vim users can always type :help! ~~


WARNING: multiple messages have this Message-ID (diff)
From: Matti Vaittinen <mazziesaccount@gmail.com>
To: Jonathan Cameron <jic23@kernel.org>
Cc: "Alexandre Belloni" <alexandre.belloni@bootlin.com>,
	"Douglas Anderson" <dianders@chromium.org>,
	linux-iio@vger.kernel.org,
	"Srinivas Pandruvada" <srinivas.pandruvada@linux.intel.com>,
	"Gwendal Grignou" <gwendal@chromium.org>,
	"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>,
	"Cosmin Tanislav" <cosmin.tanislav@analog.com>,
	"Nathan Chancellor" <nathan@kernel.org>,
	"Benson Leung" <bleung@chromium.org>,
	linux-arm-kernel@lists.infradead.org,
	"Matti Vaittinen" <matti.vaittinen@fi.rohmeurope.com>,
	linux-kernel@vger.kernel.org,
	"Eugen Hristev" <eugen.hristev@microchip.com>,
	"Claudiu Beznea" <claudiu.beznea@microchip.com>
Subject: Re: [RFT PATCH v2 2/2] iio: Fix unsafe buffer attributes
Date: Sun, 2 Oct 2022 17:25:48 +0300	[thread overview]
Message-ID: <3ebe3c45-e951-678b-ea55-89c5bf62e8bc@gmail.com> (raw)
In-Reply-To: <20221002145644.16db3aec@jic23-huawei>

On 10/2/22 16:57, Jonathan Cameron wrote:
> On Sat, 1 Oct 2022 10:44:23 +0300
> Matti Vaittinen <mazziesaccount@gmail.com> wrote:
> 
>> The iio_triggered_buffer_setup_ext() was changed by
>> commit 15097c7a1adc ("iio: buffer: wrap all buffer attributes into iio_dev_attr")
>> to silently expect that all attributes given in buffer_attrs array are
>> device-attributes. This expectation was not forced by the API - and some
>> drivers did 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 location.
>>
>> Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
>> Fixes: 15097c7a1adc ("iio: buffer: wrap all buffer attributes into iio_dev_attr")
> 
> Hi Matti,
> 
> This feels like we are doing too much in one go.
> I would start with fixes for each individual driver, then once those are in we
> come around again and do the refactor.
> 
> So for the first patch set (one per driver) just siwtch to yor new
> dev_attr but still use a struct attribute * array.
> Second series then does the refactor so we don't introduce any new instances
> in future. More churn but the code to backport is more tightly confined.

Agreed. Besides, backporting the fix to stable will be much easier that 
way. I'll split this for v3. Thanks for the input!


Yours,
	--Matti

-- 
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland

~~ When things go utterly wrong vim users can always type :help! ~~


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2022-10-02 14:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-01  7:43 [RFT PATCH v2 0/2] iio: Fix unsafe buffer attributes Matti Vaittinen
2022-10-01  7:43 ` Matti Vaittinen
2022-10-01  7:44 ` [RFT PATCH v2 1/2] iio: Add IIO_STATIC_CONST_DEVICE_ATTR Matti Vaittinen
2022-10-01  7:44   ` Matti Vaittinen
2022-10-01  7:44 ` [RFT PATCH v2 2/2] iio: Fix unsafe buffer attributes Matti Vaittinen
2022-10-01  7:44   ` Matti Vaittinen
2022-10-02 13:57   ` Jonathan Cameron
2022-10-02 13:57     ` Jonathan Cameron
2022-10-02 14:25     ` Matti Vaittinen [this message]
2022-10-02 14:25       ` Matti Vaittinen

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=3ebe3c45-e951-678b-ea55-89c5bf62e8bc@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=nathan@kernel.org \
    --cc=nicolas.ferre@microchip.com \
    --cc=paul@crapouillou.net \
    --cc=srinivas.pandruvada@linux.intel.com \
    --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: link
Be 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.