Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH 1/2] Bluetooth: Reject invalid bdaddr types for sockets
@ 2013-10-14 18:17 johan.hedberg
  2013-10-14 18:17 ` [PATCH 2/2] Bluetooth: Check that bind() bdaddr type matches connect() johan.hedberg
  2013-10-14 18:27 ` [PATCH 1/2] Bluetooth: Reject invalid bdaddr types for sockets Marcel Holtmann
  0 siblings, 2 replies; 4+ messages in thread
From: johan.hedberg @ 2013-10-14 18:17 UTC (permalink / raw)
  To: linux-bluetooth

From: Johan Hedberg <johan.hedberg@intel.com>

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>
---
 net/bluetooth/l2cap_sock.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index f1b462f..982915d 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)
 	if (la.l2_cid && la.l2_psm)
 		return -EINVAL;
 
+	if (!bdaddr_type_is_valid(la.l2_bdaddr_type))
+		return -EINVAL;
+
 	lock_sock(sk);
 
 	if (sk->sk_state != BT_OPEN) {
@@ -144,6 +147,9 @@ static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr,
 	if (la.l2_cid && la.l2_psm)
 		return -EINVAL;
 
+	if (!bdaddr_type_is_valid(la.l2_bdaddr_type))
+		return -EINVAL;
+
 	err = l2cap_chan_connect(chan, la.l2_psm, __le16_to_cpu(la.l2_cid),
 				 &la.l2_bdaddr, la.l2_bdaddr_type);
 	if (err)
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] Bluetooth: Check that bind() bdaddr type matches connect()
  2013-10-14 18:17 [PATCH 1/2] Bluetooth: Reject invalid bdaddr types for sockets johan.hedberg
@ 2013-10-14 18:17 ` johan.hedberg
  2013-10-14 18:27   ` Marcel Holtmann
  2013-10-14 18:27 ` [PATCH 1/2] Bluetooth: Reject invalid bdaddr types for sockets Marcel Holtmann
  1 sibling, 1 reply; 4+ messages in thread
From: johan.hedberg @ 2013-10-14 18:17 UTC (permalink / raw)
  To: linux-bluetooth

From: Johan Hedberg <johan.hedberg@intel.com>

If a socket was bound to an address type other than BR/EDR (such as LE)
we should reject trying to connect it to a BR/EDR address. The same
applies for binding to BR/EDR and trying to connect to non-BR/EDR.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
 net/bluetooth/l2cap_sock.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 982915d..87e17b7 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -150,6 +150,12 @@ static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr,
 	if (!bdaddr_type_is_valid(la.l2_bdaddr_type))
 		return -EINVAL;
 
+	if (chan->src_type == BDADDR_BREDR && la.l2_bdaddr_type != BDADDR_BREDR)
+		return -EINVAL;
+
+	if (chan->src_type != BDADDR_BREDR && la.l2_bdaddr_type == BDADDR_BREDR)
+		return -EINVAL;
+
 	err = l2cap_chan_connect(chan, la.l2_psm, __le16_to_cpu(la.l2_cid),
 				 &la.l2_bdaddr, la.l2_bdaddr_type);
 	if (err)
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] Bluetooth: Reject invalid bdaddr types for sockets
  2013-10-14 18:17 [PATCH 1/2] Bluetooth: Reject invalid bdaddr types for sockets johan.hedberg
  2013-10-14 18:17 ` [PATCH 2/2] Bluetooth: Check that bind() bdaddr type matches connect() johan.hedberg
@ 2013-10-14 18:27 ` Marcel Holtmann
  1 sibling, 0 replies; 4+ messages in thread
From: Marcel Holtmann @ 2013-10-14 18:27 UTC (permalink / raw)
  To: johan.hedberg; +Cc: linux-bluetooth

Hi Johan,

> 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>
> ---
> net/bluetooth/l2cap_sock.c | 6 ++++++
> 1 file changed, 6 insertions(+)

patch has been applied to bluetooth-next tree.

Regards

Marcel


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] Bluetooth: Check that bind() bdaddr type matches connect()
  2013-10-14 18:17 ` [PATCH 2/2] Bluetooth: Check that bind() bdaddr type matches connect() johan.hedberg
@ 2013-10-14 18:27   ` Marcel Holtmann
  0 siblings, 0 replies; 4+ messages in thread
From: Marcel Holtmann @ 2013-10-14 18:27 UTC (permalink / raw)
  To: johan.hedberg; +Cc: linux-bluetooth

Hi Johan,

> If a socket was bound to an address type other than BR/EDR (such as LE)
> we should reject trying to connect it to a BR/EDR address. The same
> applies for binding to BR/EDR and trying to connect to non-BR/EDR.
> 
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> net/bluetooth/l2cap_sock.c | 6 ++++++
> 1 file changed, 6 insertions(+)

patch has been applied to bluetooth-next tree.

Regards

Marcel


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-10-14 18:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-14 18:17 [PATCH 1/2] Bluetooth: Reject invalid bdaddr types for sockets johan.hedberg
2013-10-14 18:17 ` [PATCH 2/2] Bluetooth: Check that bind() bdaddr type matches connect() johan.hedberg
2013-10-14 18:27   ` Marcel Holtmann
2013-10-14 18:27 ` [PATCH 1/2] Bluetooth: Reject invalid bdaddr types for sockets Marcel Holtmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox