Bluetooth: Disallow to change L2CAP_OPTIONS values when connected
authorGustavo F. Padovan <padovan@profusion.mobi>
Mon, 4 Oct 2010 22:28:52 +0000 (19:28 -0300)
committerGustavo F. Padovan <padovan@profusion.mobi>
Mon, 4 Oct 2010 22:28:52 +0000 (19:28 -0300)
L2CAP doesn't permit change like MTU, FCS, TxWindow values while the
connection is alive, we can only set that before the
connection/configuration process. That can lead to bugs in the L2CAP
operation.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
net/bluetooth/l2cap.c

index 44a8fb0d6c2923f066916b7994fe5a10b9c0892c..0b54b7dd84010a52147a54155c4f8db2b61752a7 100644 (file)
@@ -1950,6 +1950,11 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, char __us
 
        switch (optname) {
        case L2CAP_OPTIONS:
+               if (sk->sk_state == BT_CONNECTED) {
+                       err = -EINVAL;
+                       break;
+               }
+
                opts.imtu     = l2cap_pi(sk)->imtu;
                opts.omtu     = l2cap_pi(sk)->omtu;
                opts.flush_to = l2cap_pi(sk)->flush_to;