Skip to contentSkip to conversation

bluetooth: bfusb: Check the endpoint type at probe

PATCH Superseded Zheyu Ma 3 participants 6 messages May 13, 2022 Bluetooth drivers

lore
Share & tools
lore

Zheyu Ma

author
#0 lore raw

PATCH 1/1 bluetooth: bfusb: Check the endpoint type at probe

The driver reported an warning in usb_submit_urb() which is caused by wrong endpoint type.

[    3.295630] usb 1-1: BOGUS urb xfer, pipe 3 != type 1
[    3.295916] WARNING: CPU: 0 PID: 33 at drivers/usb/core/urb.c:503 usb_submit_urb+0xcd9/0x18b0
[    3.298155] RIP: 0010:usb_submit_urb+0xcd9/0x18b0
[    3.302451] Call Trace:
[    3.302580]  <TASK>
[    3.302698]  bfusb_rx_submit+0x24e/0x390 [bfusb]
[    3.302938]  bfusb_open+0x50/0x90 [bfusb]

Fix this by checking the endpoint type at first.

---
 drivers/bluetooth/bfusb.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/bluetooth/bfusb.c +3 -1
index cab93935cc7f..447b6876c552 100644
@@ -613,7 +613,9 @@ static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *i
 	bulk_out_ep = &intf->cur_altsetting->endpoint[0];
 	bulk_in_ep  = &intf->cur_altsetting->endpoint[1];
 
-	if (!bulk_out_ep || !bulk_in_ep) {
+	if (!bulk_out_ep || !bulk_in_ep ||
+		!usb_endpoint_is_bulk_out(&bulk_out_ep->desc) ||
+		!usb_endpoint_is_bulk_in(&bulk_in_ep->desc)) {
 		BT_ERR("Bulk endpoints not found");
 		goto done;
 	}
Signature · 1 line
2.25.1
maintainer
#1 lore raw

Hi Zheyu,

Quoted 23 lines

The driver reported an warning in usb_submit_urb() which is caused by wrong endpoint type.

[    3.295630] usb 1-1: BOGUS urb xfer, pipe 3 != type 1
[    3.295916] WARNING: CPU: 0 PID: 33 at drivers/usb/core/urb.c:503 usb_submit_urb+0xcd9/0x18b0
[    3.298155] RIP: 0010:usb_submit_urb+0xcd9/0x18b0
[    3.302451] Call Trace:
[    3.302580]  <TASK>
[    3.302698]  bfusb_rx_submit+0x24e/0x390 [bfusb]
[    3.302938]  bfusb_open+0x50/0x90 [bfusb]

Fix this by checking the endpoint type at first.

---
drivers/bluetooth/bfusb.c | 4 +++-

1 file changed, 3 insertions(+), 1 deletion(-)
drivers/bluetooth/bfusb.c +0 -0
index cab93935cc7f..447b6876c552 100644

drivers/bluetooth/bfusb.c static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *i · line 621

Quoted 10 lines
drivers/bluetooth/bfusb.c +3 -1
@@ -613,7 +613,9 @@ static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *i
 	bulk_out_ep = &intf->cur_altsetting->endpoint[0];
 	bulk_in_ep  = &intf->cur_altsetting->endpoint[1];
 
-	if (!bulk_out_ep || !bulk_in_ep) {
+	if (!bulk_out_ep || !bulk_in_ep ||
+		!usb_endpoint_is_bulk_out(&bulk_out_ep->desc) ||
+		!usb_endpoint_is_bulk_in(&bulk_in_ep->desc)) {
 		BT_ERR("Bulk endpoints not found");
 		goto done;
 	}

how are you getting this. This driver only works on one specific piece of hardware.

Regards

Marcel

author
#2 lore raw
Quoted 29 lines · Marcel Holtmann

Hi Zheyu,

Quoted 26 lines

The driver reported an warning in usb_submit_urb() which is caused by wrong endpoint type.

[    3.295630] usb 1-1: BOGUS urb xfer, pipe 3 != type 1
[    3.295916] WARNING: CPU: 0 PID: 33 at drivers/usb/core/urb.c:503 usb_submit_urb+0xcd9/0x18b0
[    3.298155] RIP: 0010:usb_submit_urb+0xcd9/0x18b0
[    3.302451] Call Trace:
[    3.302580]  <TASK>
[    3.302698]  bfusb_rx_submit+0x24e/0x390 [bfusb]
[    3.302938]  bfusb_open+0x50/0x90 [bfusb]

Fix this by checking the endpoint type at first.

---
drivers/bluetooth/bfusb.c | 4 +++-

1 file changed, 3 insertions(+), 1 deletion(-)
drivers/bluetooth/bfusb.c +0 -0
index cab93935cc7f..447b6876c552 100644
@@ -613,7 +613,9 @@ static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *i
      bulk_out_ep = &intf->cur_altsetting->endpoint[0];
      bulk_in_ep  = &intf->cur_altsetting->endpoint[1];
 
Quoted 9 lines

drivers/bluetooth/bfusb.c static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *i · line 621

Quoted 7 lines
drivers/bluetooth/bfusb.c +3 -1
-     if (!bulk_out_ep || !bulk_in_ep) {
+     if (!bulk_out_ep || !bulk_in_ep ||
+             !usb_endpoint_is_bulk_out(&bulk_out_ep->desc) ||
+             !usb_endpoint_is_bulk_in(&bulk_in_ep->desc)) {
              BT_ERR("Bulk endpoints not found");
              goto done;
      }

how are you getting this. This driver only works on one specific piece of hardware.

Actually, I used a virtual device to test the driver, and got the above warning. The USB device may be programmable and malicious, so the driver should carefully treat the input that the device provided.

Regards,
Zheyu Ma

#3 lore raw
In reply to Zheyu Ma

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=641391

---Test result---

Test Summary:

CheckPatch                    PASS      1.62 seconds
GitLint                       FAIL      1.00 seconds
SubjectPrefix                 FAIL      0.85 seconds
BuildKernel                   PASS      37.39 seconds
BuildKernel32                 PASS      32.48 seconds
Incremental Build with patchesPASS      43.17 seconds
TestRunner: Setup             PASS      542.39 seconds
TestRunner: l2cap-tester      PASS      19.03 seconds
TestRunner: bnep-tester       PASS      6.79 seconds
TestRunner: mgmt-tester       PASS      116.84 seconds
TestRunner: rfcomm-tester     PASS      10.85 seconds
TestRunner: sco-tester        PASS      10.37 seconds
TestRunner: smp-tester        PASS      10.63 seconds
TestRunner: userchan-tester   PASS      7.00 seconds

Details
##############################
Test: GitLint - FAIL - 1.00 seconds
Run gitlint with rule in .gitlint
bluetooth: bfusb: Check the endpoint type at probe
7: B1 Line exceeds max length (96>80): "[ 3.295916] WARNING: CPU: 0 PID: 33 at drivers/usb/core/urb.c:503 usb_submit_urb+0xcd9/0x18b0"

##############################
Test: SubjectPrefix - FAIL - 0.85 seconds Check subject contains "Bluetooth" prefix "Bluetooth: " is not specified in the subject

---
Regards,
Linux Bluetooth

author
#4 lore raw

PATCH v2 1/1 Bluetooth: bfusb: Check the endpoint type at probe

In reply to Zheyu Ma

The driver reported an warning in usb_submit_urb() which is caused by wrong endpoint type.

usb 1-1: BOGUS urb xfer, pipe 3 != type 1

WARNING: at drivers/usb/core/urb.c:503 usb_submit_urb+0xcd9/0x18b0
RIP: 0010:usb_submit_urb+0xcd9/0x18b0
Call Trace:
 <TASK>
 bfusb_rx_submit+0x24e/0x390 [bfusb]
 bfusb_open+0x50/0x90 [bfusb]

Fix this by checking the endpoint type at first.

---
Changes in v2:
- Format the commit message

---
 drivers/bluetooth/bfusb.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/bluetooth/bfusb.c +3 -1
index cab93935cc7f..447b6876c552 100644
@@ -613,7 +613,9 @@ static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *i
 	bulk_out_ep = &intf->cur_altsetting->endpoint[0];
 	bulk_in_ep  = &intf->cur_altsetting->endpoint[1];
 
-	if (!bulk_out_ep || !bulk_in_ep) {
+	if (!bulk_out_ep || !bulk_in_ep ||
+		!usb_endpoint_is_bulk_out(&bulk_out_ep->desc) ||
+		!usb_endpoint_is_bulk_in(&bulk_in_ep->desc)) {
 		BT_ERR("Bulk endpoints not found");
 		goto done;
 	}
Signature · 1 line
2.25.1
#5 lore raw

RE: [v2] Bluetooth: bfusb: Check the endpoint type at probe

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=641424

---Test result---

Test Summary:

CheckPatch                    PASS      1.70 seconds
GitLint                       PASS      1.05 seconds
SubjectPrefix                 PASS      0.93 seconds
BuildKernel                   PASS      40.06 seconds
BuildKernel32                 PASS      35.18 seconds
Incremental Build with patchesPASS      47.73 seconds
TestRunner: Setup             PASS      588.75 seconds
TestRunner: l2cap-tester      PASS      19.89 seconds
TestRunner: bnep-tester       PASS      7.37 seconds
TestRunner: mgmt-tester       PASS      118.24 seconds
TestRunner: rfcomm-tester     PASS      11.25 seconds
TestRunner: sco-tester        PASS      10.99 seconds
TestRunner: smp-tester        PASS      11.14 seconds
TestRunner: userchan-tester   PASS      7.70 seconds

---
Regards,
Linux Bluetooth