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:   Mon, 29 Mar 2021 14:56:22 +0300
From:   Andy Shevchenko <andy.shevchenko@...il.com>
To:     Matti Vaittinen <matti.vaittinen@...rohmeurope.com>
Cc:     Matti Vaittinen <mazziesaccount@...il.com>,
        Linus Walleij <linus.walleij@...aro.org>,
        Bartosz Golaszewski <bgolaszewski@...libre.com>,
        Stephen Boyd <sboyd@...eaurora.org>,
        Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
        "open list:GPIO SUBSYSTEM" <linux-gpio@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 1/2] gpio: sysfs: Obey valid_mask

On Mon, Mar 29, 2021 at 2:42 PM Matti Vaittinen
<matti.vaittinen@...rohmeurope.com> wrote:
>
> Do not allow exporting GPIOs which are set invalid
> by the driver's valid mask.

> Fixes: 726cb3ba49692bdae6caff457755e7cdb432efa4
>
> Signed-off-by: Matti Vaittinen <matti.vaittinen@...rohmeurope.com>

Should not be blank lines in the tag block.

Dunno if you can convert those pr_*() to dev_*(), but it's definitely
out of the scope here.

I like the idea, FWIW,
Reviewed-by: Andy Shevchenko <andy.shevchenko@...il.com>

> ---
>  drivers/gpio/gpiolib-sysfs.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/drivers/gpio/gpiolib-sysfs.c b/drivers/gpio/gpiolib-sysfs.c
> index 26c5466b8179..ae49bb23c6ed 100644
> --- a/drivers/gpio/gpiolib-sysfs.c
> +++ b/drivers/gpio/gpiolib-sysfs.c
> @@ -458,6 +458,8 @@ static ssize_t export_store(struct class *class,
>         long                    gpio;
>         struct gpio_desc        *desc;
>         int                     status;
> +       struct gpio_chip        *gc;
> +       int                     offset;
>
>         status = kstrtol(buf, 0, &gpio);
>         if (status < 0)
> @@ -469,6 +471,12 @@ static ssize_t export_store(struct class *class,
>                 pr_warn("%s: invalid GPIO %ld\n", __func__, gpio);
>                 return -EINVAL;
>         }
> +       gc = desc->gdev->chip;
> +       offset = gpio_chip_hwgpio(desc);
> +       if (!gpiochip_line_is_valid(gc, offset)) {
> +               pr_warn("%s: GPIO %ld masked\n", __func__, gpio);
> +               return -EINVAL;
> +       }
>
>         /* No extra locking here; FLAG_SYSFS just signifies that the
>          * request and export were done by on behalf of userspace, so
> --
> 2.25.4
>
>
> --
> 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 =]



-- 
With Best Regards,
Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ