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]
Date:   Fri, 12 May 2023 09:24:26 +0200
From:   Johan Hovold <johan@...nel.org>
To:     Chris Packham <chris.packham@...iedtelesis.co.nz>
Cc:     linus.walleij@...aro.org, brgl@...ev.pl, andy.shevchenko@...il.com,
        maz@...nel.org, Ben Brown <ben.brown@...iedtelesis.co.nz>,
        linux-gpio@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] gpiolib: Avoid side effects in gpio_is_visible()

On Fri, May 12, 2023 at 04:28:06PM +1200, Chris Packham wrote:
> Calling gpiod_to_irq() creates an irq_desc for the GPIO. This is not
> something that should happen when just exporting the GPIO via sysfs. The
> effect of this was observed as triggering a warning in
> gpiochip_disable_irq() when kexec()ing after exporting a GPIO.

You need a better explanation as to why this is an issue. What does the
warning look like for example?

> Remove the call to gpiod_to_irq() from gpio_is_visible(). The actual
> intended creation of the irq_desc comes via edge_store() when requested
> by the user.

And why does that avoid whatever problem you're seeing?

> Fixes: ebbeba120ab2 ("gpio: sysfs: fix gpio attribute-creation race")

This is clearly not the right Fixes tag. The above commit only moved the
creation of the attribute to before registering the sysfs device and
specifically gpiod_to_irq() was used also prior to that commit.

As a matter of fact, back then there was no call to
irq_create_mapping() in gpiod_to_irq() either. That was added years
later by commit

	dc749a09ea5e ("gpiolib: allow gpio irqchip to map irqs dynamically")

> Signed-off-by: Chris Packham <chris.packham@...iedtelesis.co.nz>
> ---
> 
> Notes:
>     This is technically a v2 of
>     https://lore.kernel.org/lkml/20230510001151.3946931-1-chris.packham@alliedtelesis.co.nz/
>     but the solution is so different it's probably best to treat it as a new
>     patch.
> 
>  drivers/gpio/gpiolib-sysfs.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/gpio/gpiolib-sysfs.c b/drivers/gpio/gpiolib-sysfs.c
> index 530dfd19d7b5..f859dcd1cbf3 100644
> --- a/drivers/gpio/gpiolib-sysfs.c
> +++ b/drivers/gpio/gpiolib-sysfs.c
> @@ -362,8 +362,6 @@ static umode_t gpio_is_visible(struct kobject *kobj, struct attribute *attr,
>  		if (!show_direction)
>  			mode = 0;
>  	} else if (attr == &dev_attr_edge.attr) {
> -		if (gpiod_to_irq(desc) < 0)
> -			mode = 0;
>  		if (!show_direction && test_bit(FLAG_IS_OUT, &desc->flags))
>  			mode = 0;
>  	}

Johan

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ