Skip to contentSkip to conversation

Bluetooth: Fix returning peer address in pending connect state

PATCH In review [email protected] 2 participants 2 messages Mar 26, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Bluetooth: Fix returning peer address in pending connect state

From: Johan Hedberg <[email protected]>

We should let user space request the peer address also in the pending connect states, i.e. BT_CONNECT and BT_CONNECT2. There is existing user space code that tries to do this and will fail without extending the set of allowed states for the peer address information.

This patch adds the two states to the allowed ones in the L2CAP and RFCOMM sock_getname functions, thereby preventing ENOTCONN from being returned.

---
This was reported as a regression on its way to 3.15 so we should either send an immediate pull with it for wireless-next or then have it go in in the very first patch to the 3.15-rc kernels.

 net/bluetooth/l2cap_sock.c  | 3 ++-
 net/bluetooth/rfcomm/sock.c | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)
net/bluetooth/l2cap_sock.c +2 -1
index 33cd5615ff1e..f59e00c2daa9 100644
@@ -360,7 +360,8 @@ static int l2cap_sock_getname(struct socket *sock, struct sockaddr *addr,
 
 	BT_DBG("sock %p, sk %p", sock, sk);
 
-	if (peer && sk->sk_state != BT_CONNECTED)
+	if (peer && sk->sk_state != BT_CONNECTED &&
+	    sk->sk_state != BT_CONNECT && sk->sk_state != BT_CONNECT2)
 		return -ENOTCONN;
 
 	memset(la, 0, sizeof(struct sockaddr_l2));
net/bluetooth/rfcomm/sock.c +2 -1
index c024e715512f..eabd25ab5ad9 100644
@@ -534,7 +534,8 @@ static int rfcomm_sock_getname(struct socket *sock, struct sockaddr *addr, int *
 
 	BT_DBG("sock %p, sk %p", sock, sk);
 
-	if (peer && sk->sk_state != BT_CONNECTED)
+	if (peer && sk->sk_state != BT_CONNECTED &&
+	    sk->sk_state != BT_CONNECT && sk->sk_state != BT_CONNECT2)
 		return -ENOTCONN;
 
 	memset(sa, 0, sizeof(*sa));
Signature · 1 line
1.9.0
maintainer
#1 lore raw

Hi Johan,

Quoted 12 lines

We should let user space request the peer address also in the pending connect states, i.e. BT_CONNECT and BT_CONNECT2. There is existing user space code that tries to do this and will fail without extending the set of allowed states for the peer address information.

This patch adds the two states to the allowed ones in the L2CAP and RFCOMM sock_getname functions, thereby preventing ENOTCONN from being returned.

Quoted 8 lines

---
This was reported as a regression on its way to 3.15 so we should either send an immediate pull with it for wireless-next or then have it go in in the very first patch to the 3.15-rc kernels.

net/bluetooth/l2cap_sock.c | 3 ++-
net/bluetooth/rfcomm/sock.c | 3 ++-

2 files changed, 4 insertions(+), 2 deletions(-)

patch has been applied to bluetooth-next tree.

I also rebased the tree and inserted this patch just after the origin/for-upstream tag so that we can just move the tag forward and include this fix.

Regards

Marcel