Patch "Bluetooth: L2CAP: Fix L2CAP_ECRED_CONN_RSP response" has been added to the 6.12-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    Bluetooth: L2CAP: Fix L2CAP_ECRED_CONN_RSP response

to the 6.12-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     bluetooth-l2cap-fix-l2cap_ecred_conn_rsp-response.patch
and it can be found in the queue-6.12 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit a6f5a2e72e3f33ba8649cee113c42e3bc983d6ab
Author: Luiz Augusto von Dentz <luiz.von.dentz@xxxxxxxxx>
Date:   Fri Feb 14 10:30:25 2025 -0500

    Bluetooth: L2CAP: Fix L2CAP_ECRED_CONN_RSP response
    
    [ Upstream commit b25120e1d5f2ebb3db00af557709041f47f7f3d0 ]
    
    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
    
    Also make sure the response don't include channels that are not on
    BT_CONNECT2 since the chan->ident can be set to the same value as in the
    following trace:
    
    < ACL Data TX: Handle 16 flags 0x00 dlen 12
          LE L2CAP: LE Flow Control Credit (0x16) ident 6 len 4
            Source CID: 64
            Credits: 1
    ...
    > ACL Data RX: Handle 16 flags 0x02 dlen 18
          LE L2CAP: Enhanced Credit Connection Request (0x17) ident 6 len 10
            PSM: 39 (0x0027)
            MTU: 517
            MPS: 251
            Credits: 255
            Source CID: 70
    < ACL Data TX: Handle 16 flags 0x00 dlen 20
          LE L2CAP: Enhanced Credit Connection Response (0x18) ident 6 len 12
            MTU: 517
            MPS: 247
            Credits: 3
            Result: Connection successful (0x0000)
            Destination CID: 64
            Destination CID: 68
    
    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@xxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 27b4c4a2ba1fd..728a5ce9b5058 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -636,7 +636,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)
@@ -3776,7 +3777,11 @@ static void l2cap_ecred_rsp_defer(struct l2cap_chan *chan, void *data)
 	struct l2cap_ecred_conn_rsp *rsp_flex =
 		container_of(&rsp->pdu.rsp, struct l2cap_ecred_conn_rsp, hdr);
 
-	if (test_bit(FLAG_ECRED_CONN_REQ_SENT, &chan->flags))
+	/* Check if channel for outgoing connection or if it wasn't deferred
+	 * since in those cases it must be skipped.
+	 */
+	if (test_bit(FLAG_ECRED_CONN_REQ_SENT, &chan->flags) ||
+	    !test_and_clear_bit(FLAG_DEFER_SETUP, &chan->flags))
 		return;
 
 	/* Reset ident so only one response is sent */




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux