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: <CAMRc=MfjZC1e84eHWaxPBK9Ui_CpeVDDaF+xrQxx3Q63nFr8uA@mail.gmail.com>
Date: Fri, 12 Jul 2024 20:23:31 +0200
From: Bartosz Golaszewski <brgl@...ev.pl>
To: Dan Carpenter <dan.carpenter@...aro.org>
Cc: Krzysztof Kozlowski <krzk@...nel.org>, linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org, 
	Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
Subject: Re: [PATCH] power: sequencing: fix NULL-pointer dereference in error path

On Fri, Jul 12, 2024 at 5:24 PM Dan Carpenter <dan.carpenter@...aro.org> wrote:
>
> On Fri, Jul 12, 2024 at 05:02:25PM +0200, Bartosz Golaszewski wrote:
> > On Fri, Jul 12, 2024 at 4:59 PM Dan Carpenter <dan.carpenter@...aro.org> wrote:
> > >
> > > On Fri, Jul 12, 2024 at 04:45:46PM +0200, Bartosz Golaszewski wrote:
> > > > From: Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
> > > >
> > > > We may call pwrseq_target_free() on a target without the final unit
> > > > assigned yet. In this case pwrseq_unit_put() will dereference
> > > > a NULL-pointer. Add a check to the latter function.
> > > >
> > > > Fixes: 249ebf3f65f8 ("power: sequencing: implement the pwrseq core")
> > > > Reported-by: Dan Carpenter <dan.carpenter@...aro.org>
> > > > Closes: https://lore.kernel.org/linux-pm/62a3531e-9927-40f8-b587-254a2dfa47ef@stanley.mountain/
> > > > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
> > > > ---
> > > >  drivers/power/sequencing/core.c | 3 ++-
> > > >  1 file changed, 2 insertions(+), 1 deletion(-)
> > > >
> > > > diff --git a/drivers/power/sequencing/core.c b/drivers/power/sequencing/core.c
> > > > index 9c32b07a55e7..fe07100e4b33 100644
> > > > --- a/drivers/power/sequencing/core.c
> > > > +++ b/drivers/power/sequencing/core.c
> > > > @@ -119,7 +119,8 @@ static void pwrseq_unit_release(struct kref *ref);
> > > >
> > > >  static void pwrseq_unit_put(struct pwrseq_unit *unit)
> > > >  {
> > > > -     kref_put(&unit->ref, pwrseq_unit_release);
> > > > +     if (unit)
> > >
> > > I was wondering where you would put the check.  But it needs to be:
> > >
> > >         if (!IS_ERR_OR_NULL(unit))
> > >
> > > regards,
> > > dan carpenter
> > >
> >
> > Am I missing something? pwrseq_unit_new() can only return NULL on error.
> >
>
> It's not pwrseq_unit_new() but pwrseq_unit_setup() that's the issue.
> The target->unit = pwrseq_unit_setup() assignment in
> pwrseq_do_setup_targets().
>
> regards,
> dan carpenter
>

Indeed. Thanks.

Bart

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ