* [PATCH] ep93xx: clock: Fix UAF in ep93xx_clk_register_gate()
@ 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-25 21:10 ` [PATCH] ep93xx: clock: Fix UAF in ep93xx_clk_register_gate() Nick Desaulniers
0 siblings, 2 replies; 4+ messages in thread
From: Alexander Sverdlin @ 2022-01-20 13:37 UTC (permalink / raw)
To: linux-arm-kernel
Cc: Alexander Sverdlin, Hartley Sweeten, Russell King, Nikita Shubin,
Arnd Bergmann, linux-kernel, kernel test robot, stable
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;
+ }
return &psc->hw;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] ep93xx: clock: Don't use plain integer as NULL pointer
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-25 21:10 ` [PATCH] ep93xx: clock: Fix UAF in ep93xx_clk_register_gate() Nick Desaulniers
1 sibling, 0 replies; 4+ messages in thread
From: Alexander Sverdlin @ 2022-01-20 13:37 UTC (permalink / raw)
To: linux-arm-kernel
Cc: Alexander Sverdlin, Hartley Sweeten, Russell King, Nikita Shubin,
Arnd Bergmann, linux-kernel, kernel test robot
Fix sparse warning:
arch/arm/mach-ep93xx/clock.c:210:35: sparse: sparse: Using plain integer as NULL pointer
Reported-by: kernel test robot <lkp@intel.com>
Link: https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org/thread/TLFJ6D7WGMDJSQ6XK7UZE4XR2PLRZJSV/
Signed-off-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
---
arch/arm/mach-ep93xx/clock.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm/mach-ep93xx/clock.c b/arch/arm/mach-ep93xx/clock.c
index 4aee14f18123..71c54da0c1e1 100644
--- a/arch/arm/mach-ep93xx/clock.c
+++ b/arch/arm/mach-ep93xx/clock.c
@@ -209,7 +209,7 @@ static int ep93xx_mux_determine_rate(struct clk_hw *hw,
struct clk_rate_request *req)
{
unsigned long rate = req->rate;
- struct clk *best_parent = 0;
+ struct clk *best_parent = NULL;
unsigned long __parent_rate;
unsigned long best_rate = 0, actual_rate, mclk_rate;
unsigned long best_parent_rate;
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] ep93xx: clock: Fix UAF in ep93xx_clk_register_gate()
2022-01-20 13:37 [PATCH] ep93xx: clock: Fix UAF in ep93xx_clk_register_gate() Alexander Sverdlin
2022-01-20 13:37 ` [PATCH] ep93xx: clock: Don't use plain integer as NULL pointer Alexander Sverdlin
@ 2022-01-25 21:10 ` Nick Desaulniers
2022-01-25 21:12 ` Nick Desaulniers
1 sibling, 1 reply; 4+ messages in thread
From: Nick Desaulniers @ 2022-01-25 21:10 UTC (permalink / raw)
To: Alexander Sverdlin
Cc: linux-arm-kernel, Hartley Sweeten, Russell King, Nikita Shubin,
Arnd Bergmann, linux-kernel, kernel test robot, stable
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
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ep93xx: clock: Fix UAF in ep93xx_clk_register_gate()
2022-01-25 21:10 ` [PATCH] ep93xx: clock: Fix UAF in ep93xx_clk_register_gate() Nick Desaulniers
@ 2022-01-25 21:12 ` Nick Desaulniers
0 siblings, 0 replies; 4+ messages in thread
From: Nick Desaulniers @ 2022-01-25 21:12 UTC (permalink / raw)
To: Alexander Sverdlin
Cc: linux-arm-kernel, Hartley Sweeten, Russell King, Nikita Shubin,
Arnd Bergmann, linux-kernel, kernel test robot, stable
On Tue, Jan 25, 2022 at 1:10 PM Nick Desaulniers
<ndesaulniers@google.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@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
> >
--
Thanks,
~Nick Desaulniers
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-01-25 21:13 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-20 13:37 [PATCH] ep93xx: clock: Fix UAF in ep93xx_clk_register_gate() Alexander Sverdlin
2022-01-20 13:37 ` [PATCH] ep93xx: clock: Don't use plain integer as NULL pointer Alexander Sverdlin
2022-01-25 21:10 ` [PATCH] ep93xx: clock: Fix UAF in ep93xx_clk_register_gate() Nick Desaulniers
2022-01-25 21:12 ` Nick Desaulniers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).