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: <CAMuHMdXehA_n78nLXCwBdKV=So=6Vzjt5eye7ZE4bS_BvHnzEA@mail.gmail.com>
Date:   Fri, 23 Dec 2022 10:45:03 +0100
From:   Geert Uytterhoeven <geert@...ux-m68k.org>
To:     Alexey Khoroshilov <khoroshilov@...ras.ru>
Cc:     Chris Brandt <chris.brandt@...esas.com>,
        Michael Turquette <mturquette@...libre.com>,
        Stephen Boyd <sboyd@...nel.org>,
        linux-renesas-soc@...r.kernel.org, linux-clk@...r.kernel.org,
        linux-kernel@...r.kernel.org, lvc-project@...uxtesting.org
Subject: Re: [PATCH] clk: renesas: cpg-mssr: Fix use after free if
 cpg_mssr_common_init() failed

Hi Alexey,

On Thu, Dec 22, 2022 at 11:23 PM Alexey Khoroshilov
<khoroshilov@...ras.ru> wrote:
> If cpg_mssr_common_init() fails after assigning priv to global variable
> cpg_mssr_priv, it deallocates priv, but cpg_mssr_priv keeps dangling
> pointer that potentially can be used later.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Fixes: 1f7db7bbf031 ("clk: renesas: cpg-mssr: Add early clock support")
> Signed-off-by: Alexey Khoroshilov <khoroshilov@...ras.ru>

Thanks for your patch!

> --- a/drivers/clk/renesas/renesas-cpg-mssr.c
> +++ b/drivers/clk/renesas/renesas-cpg-mssr.c
> @@ -1025,6 +1025,7 @@ static int __init cpg_mssr_common_init(struct device *dev,
>         if (priv->base)
>                 iounmap(priv->base);
>         kfree(priv);
> +       cpg_mssr_priv = NULL;

While this is correct, I think it would be better to just postpone
the initial assignment to cpg_mssr_priv until everything in
cpg_mssr_common_init() has succeeded, i.e. just below the
"return 0;" above.

>
>         return error;
>  }

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ