aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2013-10-18 06:43:01 -0400
committerJohan Hedberg <johan.hedberg@intel.com>2013-10-18 07:43:22 -0400
commitcc8dba2bc302442f96d15c027fceb7b103b20ae3 (patch)
treecd7a8a6336a4aec2cbe37262499917bafc14712e
parent06ae3314e0f67a222944155904a792399038f8be (diff)
Bluetooth: Block ATT connection on LE when device is blocked
When the remote LE device is blocked, then do not create a L2CAP channel for it. Without a channel, all packets for that connection will be dropped. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
-rw-r--r--net/bluetooth/l2cap_core.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 97572970fba2..d52bd0d32621 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -1382,14 +1382,16 @@ static struct l2cap_chan *l2cap_global_chan_by_scid(int state, u16 cid,
1382 1382
1383static void l2cap_le_conn_ready(struct l2cap_conn *conn) 1383static void l2cap_le_conn_ready(struct l2cap_conn *conn)
1384{ 1384{
1385 struct hci_conn *hcon = conn->hcon;
1385 struct sock *parent; 1386 struct sock *parent;
1386 struct l2cap_chan *chan, *pchan; 1387 struct l2cap_chan *chan, *pchan;
1388 u8 dst_type;
1387 1389
1388 BT_DBG(""); 1390 BT_DBG("");
1389 1391
1390 /* Check if we have socket listening on cid */ 1392 /* Check if we have socket listening on cid */
1391 pchan = l2cap_global_chan_by_scid(BT_LISTEN, L2CAP_CID_ATT, 1393 pchan = l2cap_global_chan_by_scid(BT_LISTEN, L2CAP_CID_ATT,
1392 &conn->hcon->src, &conn->hcon->dst); 1394 &hcon->src, &hcon->dst);
1393 if (!pchan) 1395 if (!pchan)
1394 return; 1396 return;
1395 1397
@@ -1397,6 +1399,12 @@ static void l2cap_le_conn_ready(struct l2cap_conn *conn)
1397 if (__l2cap_get_chan_by_dcid(conn, L2CAP_CID_ATT)) 1399 if (__l2cap_get_chan_by_dcid(conn, L2CAP_CID_ATT))
1398 return; 1400 return;
1399 1401
1402 dst_type = bdaddr_type(hcon, hcon->dst_type);
1403
1404 /* If device is blocked, do not create a channel for it */
1405 if (hci_blacklist_lookup(hcon->hdev, &hcon->dst, dst_type))
1406 return;
1407
1400 parent = pchan->sk; 1408 parent = pchan->sk;
1401 1409
1402 lock_sock(parent); 1410 lock_sock(parent);
@@ -1407,10 +1415,10 @@ static void l2cap_le_conn_ready(struct l2cap_conn *conn)
1407 1415
1408 chan->dcid = L2CAP_CID_ATT; 1416 chan->dcid = L2CAP_CID_ATT;
1409 1417
1410 bacpy(&chan->src, &conn->hcon->src); 1418 bacpy(&chan->src, &hcon->src);
1411 bacpy(&chan->dst, &conn->hcon->dst); 1419 bacpy(&chan->dst, &hcon->dst);
1412 chan->src_type = bdaddr_type(conn->hcon, conn->hcon->src_type); 1420 chan->src_type = bdaddr_type(hcon, hcon->src_type);
1413 chan->dst_type = bdaddr_type(conn->hcon, conn->hcon->dst_type); 1421 chan->dst_type = dst_type;
1414 1422
1415 __l2cap_chan_add(conn, chan); 1423 __l2cap_chan_add(conn, chan);
1416 1424
@@ -6438,6 +6446,9 @@ static void l2cap_att_channel(struct l2cap_conn *conn,
6438 6446
6439 BT_DBG("chan %p, len %d", chan, skb->len); 6447 BT_DBG("chan %p, len %d", chan, skb->len);
6440 6448
6449 if (hci_blacklist_lookup(hcon->hdev, &hcon->dst, hcon->dst_type))
6450 goto drop;
6451
6441 if (chan->imtu < skb->len) 6452 if (chan->imtu < skb->len)
6442 goto drop; 6453 goto drop;
6443 6454