lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220616091308.miwqkdfc77mm72hz@CAB-WSD-L081021.sigma.sbrf.ru>
Date:   Thu, 16 Jun 2022 09:13:00 +0000
From:   Dmitry Rokosov <DDRokosov@...rdevices.ru>
To:     "robh+dt@...nel.org" <robh+dt@...nel.org>,
        "jic23@...nel.org" <jic23@...nel.org>,
        "lars@...afoo.de" <lars@...afoo.de>,
        "andy.shevchenko@...il.com" <andy.shevchenko@...il.com>,
        "noname.nuno@...il.com" <noname.nuno@...il.com>
CC:     "linux-iio@...r.kernel.org" <linux-iio@...r.kernel.org>,
        kernel <kernel@...rdevices.ru>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "rockosov@...il.com" <rockosov@...il.com>
Subject: Re: [PATCH v3] iio: trigger: warn about non-registered iio trigger
 getting attempt

Hello Jonathan,

I notice the patchset from 
https://lore.kernel.org/all/20220524181150.9240-1-ddrokosov@sberdevices.ru/
is not merged to stable yet.
I think if this WARN() patch is okay for you, maybe it's better to merge
it together with the previous one. It will notify developers about this
problem as you suggested before, and the previous patchset resolves the issue
in the all IIO drivers.

What do you think about it?

On Tue, Jun 07, 2022 at 06:39:18PM +0000, Dmitry Rokosov wrote:
> As a part of patch series about wrong trigger register() and get()
> calls order in the some IIO drivers trigger initialization path:
> 
> https://lore.kernel.org/all/20220524181150.9240-1-ddrokosov@sberdevices.ru/
> 
> runtime WARN_ONCE() is added to alarm IIO driver authors who make such
> a mistake.
> 
> When an IIO driver allocates a new IIO trigger, it should register it
> before calling the get() operation. In other words, each IIO driver
> must abide by IIO trigger alloc()/register()/get() calls order.
> 
> Signed-off-by: Dmitry Rokosov <ddrokosov@...rdevices.ru>
> ---
> Changes:
> v1 -> v2: totally reworked the patch, used trig->list entry instead of
>           trig->owner as driver registration indicator.
>           It works perfectly for both builtin and built as a module
>           drivers.
> 
> v2 -> v3: changed WARN() call to WARN_ONCE() to avoid warn spamming
>           during deferred probe() as Andy suggested.
> ---
>  drivers/iio/industrialio-trigger.c | 2 ++
>  include/linux/iio/trigger.h        | 5 +++++
>  2 files changed, 7 insertions(+)
> 
> diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-trigger.c
> index f504ed351b3e..d6277e72d515 100644
> --- a/drivers/iio/industrialio-trigger.c
> +++ b/drivers/iio/industrialio-trigger.c
> @@ -581,6 +581,8 @@ struct iio_trigger *viio_trigger_alloc(struct device *parent,
>  	if (trig->name == NULL)
>  		goto free_descs;
>  
> +	INIT_LIST_HEAD(&trig->list);
> +
>  	trig->subirq_chip.name = trig->name;
>  	trig->subirq_chip.irq_mask = &iio_trig_subirqmask;
>  	trig->subirq_chip.irq_unmask = &iio_trig_subirqunmask;
> diff --git a/include/linux/iio/trigger.h b/include/linux/iio/trigger.h
> index 4c69b144677b..03b1d6863436 100644
> --- a/include/linux/iio/trigger.h
> +++ b/include/linux/iio/trigger.h
> @@ -93,6 +93,11 @@ static inline void iio_trigger_put(struct iio_trigger *trig)
>  static inline struct iio_trigger *iio_trigger_get(struct iio_trigger *trig)
>  {
>  	get_device(&trig->dev);
> +
> +	WARN_ONCE(list_empty(&trig->list),
> +		  "Getting non-registered iio trigger %s is prohibited\n",
> +		  trig->name);
> +
>  	__module_get(trig->owner);
>  
>  	return trig;
> -- 
> 2.36.0

-- 
Thank you,
Dmitry

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ