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: <CAGETcx-w4A3fz_DPqJG+9P6ETGAPv547DcnsO52gqTO1_vijsw@mail.gmail.com>
Date:   Tue, 28 Feb 2023 11:07:04 -0800
From:   Saravana Kannan <saravanak@...gle.com>
To:     jjhiblot@...phandler.com
Cc:     robh+dt@...nel.org, frowand.list@...il.com,
        gregkh@...uxfoundation.org, devicetree@...r.kernel.org,
        linux-kernel@...r.kernel.org, Marc Zyngier <maz@...nel.org>
Subject: Re: [PATCH] of: property: Add missing of_node_get() in parse_interrupt()

On Tue, Feb 28, 2023 at 9:40 AM Jean-Jacques Hiblot
<jjhiblot@...phandler.com> wrote:
>
> From: Jean Jacques Hiblot <jjhiblot@...phandler.com>
>
> As all the other parsers do, parse_interrupt() must increase the refcount
> of the device_node. Otherwise the refcount is decremented every time
> parse_interrupt() is called on this node, leading to a potential
> use-after-free.
>
> This is a regression introduced by commit f265f06af194 ("of: property:
> Fix fw_devlink handling of interrupts/interrupts-extended"). The reason is
> that of_irq_parse_one() does not increase the refcount while the previously
> used of_irq_find_parent() does.

Thanks for catching the issue Jean!

This feels like a bug in of_irq_parse_one() to me. It's returning a
reference to a node without doing a of_node_get() on it.

Rob, Marc, Do you agree?

Jean,

If they agree, can you please fix of_irq_parse_one() and add a
of_node_put() to existing callers (if they aren't already doing a
put()).

Thanks,
Saravana

>
> Fixes: f265f06af194 ("of: property: Fix fw_devlink handling of interrupts/interrupts-extended")
> Signed-off-by: Jean Jacques Hiblot <jjhiblot@...phandler.com>
> ---
>  drivers/of/property.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/of/property.c b/drivers/of/property.c
> index 134cfc980b70b..1f23bcb765c4e 100644
> --- a/drivers/of/property.c
> +++ b/drivers/of/property.c
> @@ -1380,7 +1380,10 @@ static struct device_node *parse_interrupts(struct device_node *np,
>             strcmp(prop_name, "interrupts-extended"))
>                 return NULL;
>
> -       return of_irq_parse_one(np, index, &sup_args) ? NULL : sup_args.np;
> +       if (of_irq_parse_one(np, index, &sup_args))
> +               return NULL;
> +
> +       return of_node_get(sup_args.np);
>  }
>
>  static const struct supplier_bindings of_supplier_bindings[] = {
> --
> 2.25.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ