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: <CAKwvOdno9jyF4Kmy3ygHANZCsqygQk0gW32Mc59j0Xe16rv6=w@mail.gmail.com>
Date:   Tue, 25 Jan 2022 13:12:17 -0800
From:   Nick Desaulniers <ndesaulniers@...gle.com>
To:     Alexander Sverdlin <alexander.sverdlin@...il.com>
Cc:     linux-arm-kernel@...ts.infradead.org,
        Hartley Sweeten <hsweeten@...ionengravers.com>,
        Russell King <linux@...linux.org.uk>,
        Nikita Shubin <nikita.shubin@...uefel.me>,
        Arnd Bergmann <arnd@...db.de>, linux-kernel@...r.kernel.org,
        kernel test robot <lkp@...el.com>, stable@...r.kernel.org
Subject: Re: [PATCH] ep93xx: clock: Fix UAF in ep93xx_clk_register_gate()

On Tue, Jan 25, 2022 at 1:10 PM Nick Desaulniers
<ndesaulniers@...gle.com> wrote:
>
> On Thu, Jan 20, 2022 at 02:37:38PM +0100, Alexander Sverdlin wrote:

Also, consider adding the first line of the warning to your commit
message, please:
arch/arm/mach-ep93xx/clock.c:154:2: warning: Use of memory after it is
freed [clang-analyzer-unix.Malloc]

> > arch/arm/mach-ep93xx/clock.c:151:2: note: Taking true branch
> > if (IS_ERR(clk))
> > ^
> > arch/arm/mach-ep93xx/clock.c:152:3: note: Memory is released
> > kfree(psc);
> > ^~~~~~~~~~
> > arch/arm/mach-ep93xx/clock.c:154:2: note: Use of memory after it is freed
> > return &psc->hw;
> > ^ ~~~~~~~~
> >
> > Link: https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org/thread/B5YCO2NJEXINCYE26Y255LCVMO55BGWW/
> > Reported-by: kernel test robot <lkp@...el.com>
> > Fixes: 9645ccc7bd7a ("ep93xx: clock: convert in-place to COMMON_CLK")
> > Cc: stable@...r.kernel.org
> > Signed-off-by: Alexander Sverdlin <alexander.sverdlin@...il.com>
> > ---
> >  arch/arm/mach-ep93xx/clock.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/arm/mach-ep93xx/clock.c b/arch/arm/mach-ep93xx/clock.c
> > index cc75087134d3..4aee14f18123 100644
> > --- a/arch/arm/mach-ep93xx/clock.c
> > +++ b/arch/arm/mach-ep93xx/clock.c
> > @@ -148,8 +148,10 @@ static struct clk_hw *ep93xx_clk_register_gate(const char *name,
> >       psc->lock = &clk_lock;
> >
> >       clk = clk_register(NULL, &psc->hw);
> > -     if (IS_ERR(clk))
> > +     if (IS_ERR(clk)) {
> >               kfree(psc);
> > +             return (void *)clk;
>
> Prefer ERR_CAST to the raw cast. I think that's nicer when we're already
> using the IS_ERR macros.
>
> > +     }
> >
> >       return &psc->hw;
> >  }
> > --
> > 2.34.1
> >



-- 
Thanks,
~Nick Desaulniers

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ