Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH v1] Bluetooth: L2CAP: Fix L2CAP_ECRED_CONN_RSP response
@ 2025-02-14 15:37 Luiz Augusto von Dentz
  2025-02-14 16:35 ` [v1] " bluez.test.bot
  0 siblings, 1 reply; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2025-02-14 15:37 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

L2CAP_ECRED_CONN_RSP needs to respond DCID in the same order received as
SCID but the order is reversed due to use of list_add which actually
prepend channels to the list so the response is reversed:

> ACL Data RX: Handle 16 flags 0x02 dlen 26
      LE L2CAP: Enhanced Credit Connection Request (0x17) ident 2 len 18
        PSM: 39 (0x0027)
        MTU: 256
        MPS: 251
        Credits: 65535
        Source CID: 116
        Source CID: 117
        Source CID: 118
        Source CID: 119
        Source CID: 120
< ACL Data TX: Handle 16 flags 0x00 dlen 26
      LE L2CAP: Enhanced Credit Connection Response (0x18) ident 2 len 18
        MTU: 517
        MPS: 247
        Credits: 3
        Result: Connection successful (0x0000)
        Destination CID: 68
        Destination CID: 67
        Destination CID: 66
        Destination CID: 65
        Destination CID: 64

Closes: https://github.com/bluez/bluez/issues/1094
Fixes: 9aa9d9473f15 ("Bluetooth: L2CAP: Fix responding with wrong PDU type")
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
 net/bluetooth/l2cap_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index fec11e576f31..2ffb8c35dbe2 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -632,7 +632,8 @@ void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan)
 	    test_bit(FLAG_HOLD_HCI_CONN, &chan->flags))
 		hci_conn_hold(conn->hcon);
 
-	list_add(&chan->list, &conn->chan_l);
+	/* Append to the list since the order matters for ECRED */
+	list_add_tail(&chan->list, &conn->chan_l);
 }
 
 void l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan)
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-02-15 20:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-14 15:37 [PATCH v1] Bluetooth: L2CAP: Fix L2CAP_ECRED_CONN_RSP response Luiz Augusto von Dentz
2025-02-14 16:35 ` [v1] " bluez.test.bot
2025-02-14 17:10   ` Luiz Augusto von Dentz
2025-02-14 17:59     ` Arkadiusz Bokowy
     [not found]     ` <CAGFh026Kopho-c3Oi2JmwY1SynYGnh2pcPf3-Y6Dzkjm4-hGjA@mail.gmail.com>
2025-02-14 18:05       ` Luiz Augusto von Dentz
2025-02-15 20:56         ` Arkadiusz Bokowy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox