aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2013-10-14 14:17:52 -0400
committerMarcel Holtmann <marcel@holtmann.org>2013-10-14 14:26:21 -0400
commit80c1a2e76dbb36588facb265ab364b1302f7ef8c (patch)
treea747e4a13935ddcddbf5065a04cc8baf265a060d /net
parentbfaf8c9ff17a256fe435d452e8ff5a515155ee3b (diff)
Bluetooth: Reject invalid bdaddr types for sockets
We need to verify that the bdaddr type passed to connect() and bind() is within the set of valid values. If it is not we need to cleanly fail with EINVAL. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net')
-rw-r--r--net/bluetooth/l2cap_sock.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index fcf012a422fd..3f21207d59e5 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -69,6 +69,9 @@ static int l2cap_sock_bind(struct socket *sock, struct sockaddr *addr, int alen)
69 if (la.l2_cid && la.l2_psm) 69 if (la.l2_cid && la.l2_psm)
70 return -EINVAL; 70 return -EINVAL;
71 71
72 if (!bdaddr_type_is_valid(la.l2_bdaddr_type))
73 return -EINVAL;
74
72 lock_sock(sk); 75 lock_sock(sk);
73 76
74 if (sk->sk_state != BT_OPEN) { 77 if (sk->sk_state != BT_OPEN) {
@@ -144,6 +147,9 @@ static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr,
144 if (la.l2_cid && la.l2_psm) 147 if (la.l2_cid && la.l2_psm)
145 return -EINVAL; 148 return -EINVAL;
146 149
150 if (!bdaddr_type_is_valid(la.l2_bdaddr_type))
151 return -EINVAL;
152
147 err = l2cap_chan_connect(chan, la.l2_psm, __le16_to_cpu(la.l2_cid), 153 err = l2cap_chan_connect(chan, la.l2_psm, __le16_to_cpu(la.l2_cid),
148 &la.l2_bdaddr, la.l2_bdaddr_type); 154 &la.l2_bdaddr, la.l2_bdaddr_type);
149 if (err) 155 if (err)