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: <fc8023b435f78e02c96fecbe8e7599ee.sboyd@kernel.org>
Date:   Thu, 07 Sep 2023 15:33:25 -0700
From:   Stephen Boyd <sboyd@...nel.org>
To:     Alessandro Carminati <alessandro.carminati@...il.com>
Cc:     Philip Daly <pdaly@...hat.com>,
        Michael Turquette <mturquette@...libre.com>,
        linux-clk@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] Sanitize possible_parent_show to Handle Return Value of of_clk_get_parent_name

Quoting Alessandro Carminati (2023-09-07 07:15:36)
> this is a gentle ping
> 

I couldn't read your email because it was sent to nobody
(unlisted-recipients). Can you resend with a proper To: line? 

> 
> Il giorno mar 22 ago 2023 alle ore 15:49 Alessandro Carminati
> <alessandro.carminati@...il.com> ha scritto:
> >
> > In the possible_parent_show function, ensure proper handling of the return
> > value from of_clk_get_parent_name to prevent potential issues arising from
> > a NULL return.
> > The current implementation invokes seq_puts directly on the result of
> > of_clk_get_parent_name without verifying the return value, which can lead
> > to kernel panic if the function returns NULL.
> >
> > This patch addresses the concern by introducing a check on the return
> > value of of_clk_get_parent_name. If the return value is not NULL, the

Use of_clk_get_parent_name() to signify that it is a function.

> > function proceeds to call seq_puts, providing the returned value as
> > argument.
> > However, if of_clk_get_parent_name returns NULL, the function provides a
> > static string as argument, avoiding the panic.
> >
> > Reported-by: Philip Daly <pdaly@...hat.com>
> > Signed-off-by: Alessandro Carminati (Red Hat) <alessandro.carminati@...il.com>
> > ---

It needs a Fixes tag.

> >  drivers/clk/clk.c | 11 ++++++-----
> >  1 file changed, 6 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> > index c249f9791ae8..ab999644e185 100644
> > --- a/drivers/clk/clk.c
> > +++ b/drivers/clk/clk.c
> > @@ -3416,6 +3416,7 @@ static void possible_parent_show(struct seq_file *s, struct clk_core *core,
> >                                  unsigned int i, char terminator)
> >  {
> >         struct clk_core *parent;
> > +       const char *tmp;
> >
> >         /*
> >          * Go through the following options to fetch a parent's name.
> > @@ -3436,12 +3437,12 @@ static void possible_parent_show(struct seq_file *s, struct clk_core *core,
> >                 seq_puts(s, core->parents[i].name);
> >         else if (core->parents[i].fw_name)
> >                 seq_printf(s, "<%s>(fw)", core->parents[i].fw_name);
> > -       else if (core->parents[i].index >= 0)
> > -               seq_puts(s,
> > -                        of_clk_get_parent_name(core->of_node,
> > -                                               core->parents[i].index));
> > -       else
> > +       else if (core->parents[i].index >= 0) {
> > +               tmp = of_clk_get_parent_name(core->of_node, core->parents[i].index);
> > +               seq_puts(s, tmp ? tmp : "(none)");

How about using seq_printf("%s", ...) instead? That should print out
"(null)" in the case that it is NULL, instead of "(none)" and it is a
one line change.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ