From: Nick Desaulniers <ndesaulniers@google.com>
To: Alexander Sverdlin <alexander.sverdlin@gmail.com>
Cc: linux-arm-kernel@lists.infradead.org,
Hartley Sweeten <hsweeten@visionengravers.com>,
Russell King <linux@armlinux.org.uk>,
Nikita Shubin <nikita.shubin@maquefel.me>,
Arnd Bergmann <arnd@arndb.de>,
linux-kernel@vger.kernel.org, kernel test robot <lkp@intel.com>,
stable@vger.kernel.org
Subject: Re: [PATCH] ep93xx: clock: Fix UAF in ep93xx_clk_register_gate()
Date: Tue, 25 Jan 2022 13:10:34 -0800 [thread overview]
Message-ID: <YfBm/xBJLDtU/fo5@google.com> (raw)
In-Reply-To: <20220120133739.4170298-1-alexander.sverdlin@gmail.com>
On Thu, Jan 20, 2022 at 02:37:38PM +0100, Alexander Sverdlin wrote:
> 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@intel.com>
> Fixes: 9645ccc7bd7a ("ep93xx: clock: convert in-place to COMMON_CLK")
> Cc: stable@vger.kernel.org
> Signed-off-by: Alexander Sverdlin <alexander.sverdlin@gmail.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
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
WARNING: multiple messages have this Message-ID (diff)
From: Nick Desaulniers <ndesaulniers@google.com>
To: Alexander Sverdlin <alexander.sverdlin@gmail.com>
Cc: linux-arm-kernel@lists.infradead.org,
Hartley Sweeten <hsweeten@visionengravers.com>,
Russell King <linux@armlinux.org.uk>,
Nikita Shubin <nikita.shubin@maquefel.me>,
Arnd Bergmann <arnd@arndb.de>,
linux-kernel@vger.kernel.org, kernel test robot <lkp@intel.com>,
stable@vger.kernel.org
Subject: Re: [PATCH] ep93xx: clock: Fix UAF in ep93xx_clk_register_gate()
Date: Tue, 25 Jan 2022 13:10:34 -0800 [thread overview]
Message-ID: <YfBm/xBJLDtU/fo5@google.com> (raw)
In-Reply-To: <20220120133739.4170298-1-alexander.sverdlin@gmail.com>
On Thu, Jan 20, 2022 at 02:37:38PM +0100, Alexander Sverdlin wrote:
> 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@intel.com>
> Fixes: 9645ccc7bd7a ("ep93xx: clock: convert in-place to COMMON_CLK")
> Cc: stable@vger.kernel.org
> Signed-off-by: Alexander Sverdlin <alexander.sverdlin@gmail.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
>
next prev parent reply other threads:[~2022-01-25 21:12 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-20 13:37 [PATCH] ep93xx: clock: Fix UAF in ep93xx_clk_register_gate() Alexander Sverdlin
2022-01-20 13:37 ` Alexander Sverdlin
2022-01-20 13:37 ` [PATCH] ep93xx: clock: Don't use plain integer as NULL pointer Alexander Sverdlin
2022-01-20 13:37 ` Alexander Sverdlin
2022-01-25 21:10 ` Nick Desaulniers [this message]
2022-01-25 21:10 ` [PATCH] ep93xx: clock: Fix UAF in ep93xx_clk_register_gate() Nick Desaulniers
2022-01-25 21:12 ` Nick Desaulniers
2022-01-25 21:12 ` Nick Desaulniers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YfBm/xBJLDtU/fo5@google.com \
--to=ndesaulniers@google.com \
--cc=alexander.sverdlin@gmail.com \
--cc=arnd@arndb.de \
--cc=hsweeten@visionengravers.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=lkp@intel.com \
--cc=nikita.shubin@maquefel.me \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.