* [PATCH next] Bluetooth: L2CAP: Fix NULL dereference in l2cap_recv_acldata()
@ 2025-02-12 16:40 Dan Carpenter
2025-02-12 22:23 ` Luiz Augusto von Dentz
0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2025-02-12 16:40 UTC (permalink / raw)
To: Luiz Augusto von Dentz
Cc: Marcel Holtmann, Johan Hedberg, Luiz Augusto von Dentz,
linux-bluetooth, linux-kernel, kernel-janitors
The "conn" pointer is NULL so this "goto drop;" will lead to a NULL
dereference when we call mutex_unlock(&conn->lock). Free the skb and
return directly instead.
Fixes: dd6367916d2d ("Bluetooth: L2CAP: Fix corrupted list in hci_chan_del")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
net/bluetooth/l2cap_core.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 6cdc1dc3a7f9..fec11e576f31 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -7456,8 +7456,10 @@ void l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags)
hci_dev_unlock(hcon->hdev);
- if (!conn)
- goto drop;
+ if (!conn) {
+ kfree_skb(skb);
+ return;
+ }
BT_DBG("conn %p len %u flags 0x%x", conn, skb->len, flags);
--
2.47.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH next] Bluetooth: L2CAP: Fix NULL dereference in l2cap_recv_acldata()
2025-02-12 16:40 [PATCH next] Bluetooth: L2CAP: Fix NULL dereference in l2cap_recv_acldata() Dan Carpenter
@ 2025-02-12 22:23 ` Luiz Augusto von Dentz
2025-02-13 5:21 ` Dan Carpenter
0 siblings, 1 reply; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2025-02-12 22:23 UTC (permalink / raw)
To: Dan Carpenter
Cc: Luiz Augusto von Dentz, Marcel Holtmann, Johan Hedberg,
linux-bluetooth, linux-kernel, kernel-janitors
Hi Dan,
On Wed, Feb 12, 2025 at 11:40 AM Dan Carpenter <dan.carpenter@linaro.org> wrote:
>
> The "conn" pointer is NULL so this "goto drop;" will lead to a NULL
> dereference when we call mutex_unlock(&conn->lock). Free the skb and
> return directly instead.
>
> Fixes: dd6367916d2d ("Bluetooth: L2CAP: Fix corrupted list in hci_chan_del")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
> net/bluetooth/l2cap_core.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
> index 6cdc1dc3a7f9..fec11e576f31 100644
> --- a/net/bluetooth/l2cap_core.c
> +++ b/net/bluetooth/l2cap_core.c
> @@ -7456,8 +7456,10 @@ void l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags)
>
> hci_dev_unlock(hcon->hdev);
>
> - if (!conn)
> - goto drop;
> + if (!conn) {
> + kfree_skb(skb);
> + return;
> + }
>
> BT_DBG("conn %p len %u flags 0x%x", conn, skb->len, flags);
>
> --
> 2.47.2
I went ahead and fixed this in place since it has not been sent to net
yet, I did add your Signed-off-by though.
--
Luiz Augusto von Dentz
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH next] Bluetooth: L2CAP: Fix NULL dereference in l2cap_recv_acldata()
2025-02-12 22:23 ` Luiz Augusto von Dentz
@ 2025-02-13 5:21 ` Dan Carpenter
0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2025-02-13 5:21 UTC (permalink / raw)
To: Luiz Augusto von Dentz
Cc: Luiz Augusto von Dentz, Marcel Holtmann, Johan Hedberg,
linux-bluetooth, linux-kernel, kernel-janitors
On Wed, Feb 12, 2025 at 05:23:42PM -0500, Luiz Augusto von Dentz wrote:
> Hi Dan,
>
> On Wed, Feb 12, 2025 at 11:40 AM Dan Carpenter <dan.carpenter@linaro.org> wrote:
> >
> > The "conn" pointer is NULL so this "goto drop;" will lead to a NULL
> > dereference when we call mutex_unlock(&conn->lock). Free the skb and
> > return directly instead.
> >
> > Fixes: dd6367916d2d ("Bluetooth: L2CAP: Fix corrupted list in hci_chan_del")
> > Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> > ---
> > net/bluetooth/l2cap_core.c | 6 ++++--
> > 1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
> > index 6cdc1dc3a7f9..fec11e576f31 100644
> > --- a/net/bluetooth/l2cap_core.c
> > +++ b/net/bluetooth/l2cap_core.c
> > @@ -7456,8 +7456,10 @@ void l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags)
> >
> > hci_dev_unlock(hcon->hdev);
> >
> > - if (!conn)
> > - goto drop;
> > + if (!conn) {
> > + kfree_skb(skb);
> > + return;
> > + }
> >
> > BT_DBG("conn %p len %u flags 0x%x", conn, skb->len, flags);
> >
> > --
> > 2.47.2
>
> I went ahead and fixed this in place since it has not been sent to net
> yet, I did add your Signed-off-by though.
Thanks.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-02-13 5:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-12 16:40 [PATCH next] Bluetooth: L2CAP: Fix NULL dereference in l2cap_recv_acldata() Dan Carpenter
2025-02-12 22:23 ` Luiz Augusto von Dentz
2025-02-13 5:21 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®