Commit 2a517ca6 authored by Marcel Holtmann's avatar Marcel Holtmann

Bluetooth: Disallow usage of L2CAP CID setting for now

In the future the L2CAP layer will have full support for fixed channels
and right now it already can export the channel assignment, but for the
functions bind() and connect() the usage of only CID 0 is allowed. This
allows an easy detection if the kernel supports fixed channels or not,
because otherwise it would impossible for application to tell.
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent 8bf47941
...@@ -799,6 +799,9 @@ static int l2cap_sock_bind(struct socket *sock, struct sockaddr *addr, int alen) ...@@ -799,6 +799,9 @@ static int l2cap_sock_bind(struct socket *sock, struct sockaddr *addr, int alen)
len = min_t(unsigned int, sizeof(la), alen); len = min_t(unsigned int, sizeof(la), alen);
memcpy(&la, addr, len); memcpy(&la, addr, len);
if (la.l2_cid)
return -EINVAL;
lock_sock(sk); lock_sock(sk);
if (sk->sk_state != BT_OPEN) { if (sk->sk_state != BT_OPEN) {
...@@ -929,19 +932,20 @@ static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr, int al ...@@ -929,19 +932,20 @@ static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr, int al
struct sockaddr_l2 la; struct sockaddr_l2 la;
int len, err = 0; int len, err = 0;
lock_sock(sk);
BT_DBG("sk %p", sk); BT_DBG("sk %p", sk);
if (!addr || addr->sa_family != AF_BLUETOOTH) { if (!addr || addr->sa_family != AF_BLUETOOTH)
err = -EINVAL; return -EINVAL;
goto done;
}
memset(&la, 0, sizeof(la)); memset(&la, 0, sizeof(la));
len = min_t(unsigned int, sizeof(la), alen); len = min_t(unsigned int, sizeof(la), alen);
memcpy(&la, addr, len); memcpy(&la, addr, len);
if (la.l2_cid)
return -EINVAL;
lock_sock(sk);
if (sk->sk_type == SOCK_SEQPACKET && !la.l2_psm) { if (sk->sk_type == SOCK_SEQPACKET && !la.l2_psm) {
err = -EINVAL; err = -EINVAL;
goto done; goto done;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment