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: <CABBYNZJ+E6KMyqODib_nhGJuZzWssSrswKR9MoqPrM7tuEpDcg@mail.gmail.com>
Date:   Thu, 26 May 2022 13:11:56 -0700
From:   Luiz Augusto von Dentz <luiz.dentz@...il.com>
To:     Paolo Abeni <pabeni@...hat.com>
Cc:     Jianglei Nie <niejianglei2021@....com>, marcel@...tmann.org,
        johan.hedberg@...il.com, davem@...emloft.net, edumazet@...gle.com,
        kuba@...nel.org, linux-bluetooth@...r.kernel.org,
        netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] Bluetooth: hci_conn: fix potential double free in le_scan_cleanup()

Hi,

On Thu, May 26, 2022 at 4:24 AM Paolo Abeni <pabeni@...hat.com> wrote:
>
> On Thu, 2022-05-26 at 17:49 +0800, Jianglei Nie wrote:
> > When "c == conn" is true, hci_conn_cleanup() is called. The
> > hci_conn_cleanup() calls hci_dev_put() and hci_conn_put() in
> > its function implementation. hci_dev_put() and hci_conn_put()
> > will free the relevant resource if the reference count reaches
> > zero, which may lead to a double free when hci_dev_put() and
> > hci_conn_put() are called again.
> >
> > We should add a return to this function after hci_conn_cleanup()
> > is called.
> >
> > Signed-off-by: Jianglei Nie <niejianglei2021@....com>
> > ---
> >  net/bluetooth/hci_conn.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
> > index fe803bee419a..7b3e91eb9fa3 100644
> > --- a/net/bluetooth/hci_conn.c
> > +++ b/net/bluetooth/hci_conn.c
> > @@ -166,6 +166,7 @@ static void le_scan_cleanup(struct work_struct *work)
> >       if (c == conn) {
> >               hci_connect_le_scan_cleanup(conn);
> >               hci_conn_cleanup(conn);
> > +             return;
>
> This looks not correct. At very least you should release the
> hci_dev_lock.

Yep, it should probably use break instead of return.

> Cheers,
>
> Paolo
>


-- 
Luiz Augusto von Dentz

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ