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]
Date: Fri, 26 Apr 2024 05:35:01 -0400
From: Sungwoo Kim <iam@...g-woo.kim>
To: Dan Carpenter <dan.carpenter@...aro.org>
Cc: daveti@...due.edu, Marcel Holtmann <marcel@...tmann.org>, 
	Johan Hedberg <johan.hedberg@...il.com>, Luiz Augusto von Dentz <luiz.dentz@...il.com>, 
	linux-bluetooth@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] Bluetooth: L2CAP: Fix slab-use-after-free in l2cap_send_cmd

On Fri, Apr 26, 2024 at 5:16 AM Dan Carpenter <dan.carpenter@...aroorg> wrote:
>
> On Fri, Apr 26, 2024 at 03:20:05AM -0400, Sungwoo Kim wrote:
> > diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
> > index 84fc70862..a8f414ab8 100644
> > --- a/net/bluetooth/l2cap_core.c
> > +++ b/net/bluetooth/l2cap_core.c
> > @@ -3953,6 +3953,9 @@ static struct l2cap_chan *l2cap_connect(struct l2cap_conn *conn,
> >       if (!chan)
> >               goto response;
> >
> > +     l2cap_chan_hold(chan);
> > +     l2cap_chan_lock(chan);
> > +
> >       /* For certain devices (ex: HID mouse), support for authentication,
> >        * pairing and bonding is optional. For such devices, inorder to avoid
> >        * the ACL alive for too long after L2CAP disconnection, reset the ACL
> > @@ -4041,6 +4044,11 @@ static struct l2cap_chan *l2cap_connect(struct l2cap_conn *conn,
> >               chan->num_conf_req++;
> >       }
> >
> > +     if (chan) {
> > +             l2cap_chan_unlock(chan);
> > +             l2cap_chan_put(chan);
> > +     }
> > +
> >       return chan;
>         ^^^^^^^^^^^^
> This doesn't fix the bug because we're returning chan.
>
> As soon as you call l2cap_chan_put() then chan will be freed by in the
> other thread which is doing l2cap_conn_del() resulting in a use after
> free in the caller.

Thank you for pointing this out.
No caller uses the return value of l2cap_connect() if the kernel
versions >= v6.9.
So, l2cap_connect() can return void.

One caller uses the return value of l2cap_connect() in v4.19 <= the
kernel versions <= v6.8.
In this case, the caller should unlock and put a channel.

Question: Can different patches be applied for different versions like
the above?

Thanks,
Sungwoo Kim.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ