aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/l2cap_sock.c
diff options
context:
space:
mode:
authorGustavo F. Padovan <padovan@profusion.mobi>2011-11-05 17:58:31 -0400
committerGustavo F. Padovan <padovan@profusion.mobi>2011-11-10 17:25:04 -0500
commit0bee1d60cbad24288c75573511356d450c1fd45a (patch)
tree75a6f214b3c27e0f918c34bacdc03781ea2d79ac /net/bluetooth/l2cap_sock.c
parentd45fc42323b7909829b8f27f26676c675f26551f (diff)
Bluetooth: Allow L2CAP to increase the security level
Some incomming connections needs to increase the security level by requesting encryption for example (HID keyboard case). This change allows the userspace to change it through setsockopt with defer_setup enabled. Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Diffstat (limited to 'net/bluetooth/l2cap_sock.c')
-rw-r--r--net/bluetooth/l2cap_sock.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 567b585d9805..b85e3906b3a8 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -625,8 +625,13 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch
625 625
626 chan->sec_level = sec.level; 626 chan->sec_level = sec.level;
627 627
628 if (!chan->conn)
629 break;
630
628 conn = chan->conn; 631 conn = chan->conn;
629 if (conn && chan->scid == L2CAP_CID_LE_DATA) { 632
633 /*change security for LE channels */
634 if (chan->scid == L2CAP_CID_LE_DATA) {
630 if (!conn->hcon->out) { 635 if (!conn->hcon->out) {
631 err = -EINVAL; 636 err = -EINVAL;
632 break; 637 break;
@@ -634,9 +639,14 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch
634 639
635 if (smp_conn_security(conn, sec.level)) 640 if (smp_conn_security(conn, sec.level))
636 break; 641 break;
637
638 err = 0;
639 sk->sk_state = BT_CONFIG; 642 sk->sk_state = BT_CONFIG;
643
644 /* or for ACL link, under defer_setup time */
645 } else if (sk->sk_state == BT_CONNECT2 &&
646 bt_sk(sk)->defer_setup) {
647 err = l2cap_chan_check_security(chan);
648 } else {
649 err = -EINVAL;
640 } 650 }
641 break; 651 break;
642 652