Skip to contentSkip to conversation

Bluetooth: Fix crash when using new BT_PHY option

PATCH In review Luiz Augusto von Dentz 2 participants 3 messages Feb 20, 2020

Subsystems (2)
lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH 1/1 Bluetooth: Fix crash when using new BT_PHY option

From: Luiz Augusto von Dentz <[email protected]>

This fixes the invalid check for connected socket which causes the following trace due to sco_pi(sk)->conn being NULL:

RIP: 0010:sco_sock_getsockopt+0x2ff/0x800 net/bluetooth/sco.c:966

L2CAP has also been fixed since it has the same problem.

---
 net/bluetooth/l2cap_sock.c | 2 +-
 net/bluetooth/sco.c        | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
net/bluetooth/l2cap_sock.c +1 -1
index 9fb47b2b13c9..305710446e66 100644
@@ -605,7 +605,7 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname,
 		break;
 
 	case BT_PHY:
-		if (sk->sk_state == BT_CONNECTED) {
+		if (sk->sk_state != BT_CONNECTED) {
 			err = -ENOTCONN;
 			break;
 		}
net/bluetooth/sco.c +1 -1
index 29ab3e12fb46..c8c3d38cdc7b 100644
@@ -958,7 +958,7 @@ static int sco_sock_getsockopt(struct socket *sock, int level, int optname,
 		break;
 
 	case BT_PHY:
-		if (sk->sk_state == BT_CONNECTED) {
+		if (sk->sk_state != BT_CONNECTED) {
 			err = -ENOTCONN;
 			break;
 		}
Signature · 1 line
2.21.1
maintainer
#1 lore raw

Hi Luiz,

Quoted 31 lines

This fixes the invalid check for connected socket which causes the following trace due to sco_pi(sk)->conn being NULL:

RIP: 0010:sco_sock_getsockopt+0x2ff/0x800 net/bluetooth/sco.c:966

L2CAP has also been fixed since it has the same problem.

---
net/bluetooth/l2cap_sock.c | 2 +-
net/bluetooth/sco.c | 2 +-

2 files changed, 2 insertions(+), 2 deletions(-)
net/bluetooth/l2cap_sock.c +1 -1
index 9fb47b2b13c9..305710446e66 100644
@@ -605,7 +605,7 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname,
 		break;
 
 	case BT_PHY:
-		if (sk->sk_state == BT_CONNECTED) {
+		if (sk->sk_state != BT_CONNECTED) {
 			err = -ENOTCONN;
 			break;
 		}
net/bluetooth/sco.c +0 -0
index 29ab3e12fb46..c8c3d38cdc7b 100644

net/bluetooth/sco.c static int sco_sock_getsockopt(struct socket *sock, int level, int optname, · line 964

Quoted 8 lines
net/bluetooth/sco.c +1 -1
@@ -958,7 +958,7 @@ static int sco_sock_getsockopt(struct socket *sock, int level, int optname,
 		break;
 
 	case BT_PHY:
-		if (sk->sk_state == BT_CONNECTED) {
+		if (sk->sk_state != BT_CONNECTED) {
 			err = -ENOTCONN;
 			break;
 		}

is there something wrong with your mailer? I have this patch 3 times and already applied one of them to bluetooth-next. Is the one incorrect?

Regards

Marcel

author maintainer
#2 lore raw

Hi Marcel,

Quoted 36 lines · Marcel Holtmann

Hi Luiz,

Quoted 33 lines

This fixes the invalid check for connected socket which causes the following trace due to sco_pi(sk)->conn being NULL:

RIP: 0010:sco_sock_getsockopt+0x2ff/0x800 net/bluetooth/sco.c:966

L2CAP has also been fixed since it has the same problem.

---
net/bluetooth/l2cap_sock.c | 2 +-
net/bluetooth/sco.c | 2 +-

2 files changed, 2 insertions(+), 2 deletions(-)
net/bluetooth/l2cap_sock.c +1 -1
index 9fb47b2b13c9..305710446e66 100644
@@ -605,7 +605,7 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname,
              break;
 
      case BT_PHY:
-             if (sk->sk_state == BT_CONNECTED) {
+             if (sk->sk_state != BT_CONNECTED) {
                      err = -ENOTCONN;
                      break;
              }
net/bluetooth/sco.c +0 -0
index 29ab3e12fb46..c8c3d38cdc7b 100644
@@ -958,7 +958,7 @@ static int sco_sock_getsockopt(struct socket *sock, int level, int optname,
              break;
 
Quoted 8 lines

net/bluetooth/sco.c static int sco_sock_getsockopt(struct socket *sock, int level, int optname, · line 964

Quoted 6 lines
net/bluetooth/sco.c +1 -1
      case BT_PHY:
-             if (sk->sk_state == BT_CONNECTED) {
+             if (sk->sk_state != BT_CONNECTED) {
                      err = -ENOTCONN;
                      break;
              }

is there something wrong with your mailer? I have this patch 3 times and already applied one of them to bluetooth-next. Is the one incorrect?

It appears my outbox had the same patch multiple times, sorry about that the intention was to to send the RFCOMM change and these got in the way, so please disregard this one.

Signature · 1 line
Luiz Augusto von Dentz