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] [day] [month] [year] [list]
Message-ID: <ca48a3e6586ca5b1afd6e1bd81c612545df60e52.camel@foss.st.com>
Date: Tue, 25 Feb 2025 14:19:46 +0100
From: Antonio Borneo <antonio.borneo@...s.st.com>
To: Marek Szyprowski <m.szyprowski@...sung.com>,
        Bartosz Golaszewski
	<brgl@...ev.pl>,
        Linus Walleij <linus.walleij@...aro.org>
CC: <linux-gpio@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
        "Bartosz
 Golaszewski" <bartosz.golaszewski@...aro.org>,
        <stable@...r.kernel.org>, <linux-stm32@...md-mailman.stormreply.com>
Subject: Re: [PATCH 1/8] gpiolib: check the return value of
 gpio_chip::get_direction()

On Wed, 2025-02-19 at 09:38 +0100, Marek Szyprowski wrote:
> Hi Bartosz,
> 
> On 10.02.2025 11:51, Bartosz Golaszewski wrote:
> > From: Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
> > 
> > As per the API contract - gpio_chip::get_direction() may fail and return
> > a negative error number. However, we treat it as if it always returned 0
> > or 1. Check the return value of the callback and propagate the error
> > number up the stack.
> > 
> > Cc: stable@...r.kernel.org
> > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
> > ---
> >   drivers/gpio/gpiolib.c | 44 +++++++++++++++++++++++++++++---------------
> >   1 file changed, 29 insertions(+), 15 deletions(-)
> > 
> > diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> > index 679ed764cb14..5d3774dc748b 100644
> > --- a/drivers/gpio/gpiolib.c
> > +++ b/drivers/gpio/gpiolib.c
> > @@ -1057,8 +1057,11 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
> >                 desc->gdev = gdev;
> >   
> >                 if (gc->get_direction && gpiochip_line_is_valid(gc, desc_index)) {
> > -                       assign_bit(FLAG_IS_OUT,
> > -                                  &desc->flags, !gc->get_direction(gc, desc_index));
> > +                       ret = gc->get_direction(gc, desc_index);
> > +                       if (ret < 0)
> > +                               goto err_cleanup_desc_srcu;
> > +
> > +                       assign_bit(FLAG_IS_OUT, &desc->flags, !ret);
> >                 } else {
> >                         assign_bit(FLAG_IS_OUT,
> >                                    &desc->flags, !gc->direction_input);
> 
> This change breaks bcm2835 pincontrol/gpio driver (and probably others) 
> in next-20250218. The problem is that some gpio lines are initially 
> configured as alternate function (i.e. uart) and .get_direction returns 
> -EINVAL for them, what in turn causes the whole gpio chip fail to 
> register. Here is the log with WARN_ON() added to line 
> drivers/pinctrl/bcm/pinctrl-bcm2835.c:350 from Raspberry Pi 4B:

Same issue with STM32 pinctrl.

I will send out shortly a patch, similar to
https://lore.kernel.org/all/20250219102750.38519-1-brgl@bgdev.pl/

Regards,
Antonio

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ