Skip to content

Commit

Permalink
Bluetooth: L2CAP: Handle security procedure non successful path
Browse files Browse the repository at this point in the history
When getting non-zero status from security procedure on BR/EDR connection,
make sure to react properly based on connection path (in or out) by sending
in first case security block response if needed and in second case release
hanging channel if exists in CONNECT context.

> ACL Data RX: Handle 11 flags 0x02 dlen 12                   [hci1] 130.819662
      L2CAP: Connection Request (0x02) ident 5 len 4
        PSM: 5 (0x0005)
        Source CID: 65
< HCI Command: Authentication Requested (0x01|0x0011) plen 2  [hci1] 130.825611
        Handle: 11
> HCI Event: Command Status (0x0f) plen 4                     [hci1] 130.826519
      Authentication Requested (0x01|0x0011) ncmd 1
        Status: Success (0x00)
> HCI Event: Link Key Request (0x17) plen 6                   [hci1] 130.827516
        Address: 00:1A:7D:DA:71:0B (cyber-blue(HK)Ltd)
< HCI Command: Host Number of Complet.. (0x03|0x0035) plen 5  [hci1] 130.828348
        Num handles: 1
        Handle: 11
        Count: 1
< ACL Data TX: Handle 11 flags 0x00 dlen 16                   [hci1] 130.829717
      L2CAP: Connection Response (0x03) ident 5 len 8
        Destination CID: 65
        Source CID: 65
        Result: Connection pending (0x0001)
        Status: Authentication pending (0x0001)
< HCI Command: Link Key Request Reply (0x01|0x000b) plen 22   [hci1] 130.830594
        Address: 00:1A:7D:DA:71:0B (cyber-blue(HK)Ltd)
        Link key: fa087afc920ffe07199c803005fc5b5f
> HCI Event: Command Complete (0x0e) plen 10                  [hci1] 130.833513
      Link Key Request Reply (0x01|0x000b) ncmd 1
        Status: Success (0x00)
        Address: 00:1A:7D:DA:71:0B (cyber-blue(HK)Ltd)
> HCI Event: PIN Code Request (0x16) plen 6                   [hci1] 130.852526
        Address: 00:1A:7D:DA:71:0B (cyber-blue(HK)Ltd)
> HCI Event: Number of Completed Packets (0x13) plen 5        [hci1] 131.071542
        Num handles: 1
        Handle: 11
        Count: 1
< HCI Command: PIN Code Request Negat.. (0x01|0x000e) plen 6  [hci1] 154.501040
        Address: 00:1A:7D:DA:71:0B (cyber-blue(HK)Ltd)
> HCI Event: Command Complete (0x0e) plen 10                  [hci1] 154.502365
      PIN Code Request Negative Reply (0x01|0x000e) ncmd 1
        Status: Success (0x00)
        Address: 00:1A:7D:DA:71:0B (cyber-blue(HK)Ltd)
> HCI Event: Auth Complete (0x06) plen 3                      [hci1] 154.503360
        Status: PIN or Key Missing (0x06)
        Handle: 11
< ACL Data TX: Handle 11 flags 0x00 dlen 16                   [hci1] 154.506130
      L2CAP: Connection Response (0x03) ident 5 len 8
        Destination CID: 65
        Source CID: 65
        Result: Connection refused - security block (0x0003)
        Status: No further information available (0x0000)
> HCI Event: Number of Completed Packets (0x13) plen 5        [hci1] 154.699369
        Num handles: 1
        Handle: 11
        Count: 1

Change-Id: I9e9a9b456c00452efb4f5303aa1b1fd1fa81b758
Signed-off-by: Arkadiusz Lichwa <[email protected]>
  • Loading branch information
xpuarli authored and Johan Hedberg committed Oct 21, 2016
1 parent d99e0c3 commit be817c8
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions net/bluetooth/l2cap_br.c
Original file line number Diff line number Diff line change
Expand Up @@ -1575,6 +1575,23 @@ static void l2cap_br_conn_pend(struct bt_l2cap_chan *chan, uint8_t status)
BT_DBG("chan %p status 0x%02x encr 0x%02x", chan, status,
chan->conn->encrypt);

if (status) {
/*
* Security procedure status is non-zero so respond with
* security violation only as channel acceptor.
*/
l2cap_br_conn_req_reply(chan, BT_L2CAP_ERR_SEC_BLOCK);

/* Release channel allocated to outgoing connection request */
if (atomic_test_bit(BR_CHAN(chan)->flags,
L2CAP_FLAG_CONN_PENDING)) {
l2cap_br_detach_chan(chan->conn, chan);
bt_l2cap_chan_del(chan);
}

return;
}

if (!chan->conn->encrypt) {
return;
}
Expand Down

0 comments on commit be817c8

Please sign in to comment.