Skip to contentSkip to conversation

Bluetooth: hci_event: Fix HCI_EV_VENDOR max_len

PATCH In review Luiz Augusto von Dentz 4 participants 7 messages Jan 25, 2022 – Mar 14, 2022

Subsystems (2)
lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH 1/1 Bluetooth: hci_event: Fix HCI_EV_VENDOR max_len

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

HCI_EV_VENDOR is in fact variable length since it acts as metaevent where a vendor can implement their own event sets.

In addition to it this makes use of bt_dev_warn_ratelimited to supress the amount of logging in case the event has more data than expected.

Fixes 3e54c5890c87 ("Bluetooth: hci_event: Use of a function table to handle HCI event")
---
 net/bluetooth/hci_event.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
net/bluetooth/hci_event.c +4 -3
index 664ccf1d8d93..63b925921c87 100644
@@ -6844,7 +6844,7 @@ static const struct hci_ev {
 	HCI_EV(HCI_EV_NUM_COMP_BLOCKS, hci_num_comp_blocks_evt,
 	       sizeof(struct hci_ev_num_comp_blocks)),
 	/* [0xff = HCI_EV_VENDOR] */
-	HCI_EV(HCI_EV_VENDOR, msft_vendor_evt, 0),
+	HCI_EV_VL(HCI_EV_VENDOR, msft_vendor_evt, 0, HCI_MAX_EVENT_SIZE),
 };
 
 static void hci_event_func(struct hci_dev *hdev, u8 event, struct sk_buff *skb,
@@ -6869,8 +6869,9 @@ static void hci_event_func(struct hci_dev *hdev, u8 event, struct sk_buff *skb,
 	 * decide if that is acceptable.
 	 */
 	if (skb->len > ev->max_len)
-		bt_dev_warn(hdev, "unexpected event 0x%2.2x length: %u > %u",
-			    event, skb->len, ev->max_len);
+		bt_dev_warn_ratelimited(hdev,
+					"unexpected event 0x%2.2x length: %u > %u",
+					event, skb->len, ev->max_len);
 
 	data = hci_ev_skb_pull(hdev, skb, event, ev->min_len);
 	if (!data)
Signature · 1 line
2.34.1
#1 lore raw

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=608383

---Test result---

Test Summary:

CheckPatch                    FAIL      0.93 seconds
GitLint                       PASS      0.37 seconds
SubjectPrefix                 PASS      0.21 seconds
BuildKernel                   PASS      39.46 seconds
BuildKernel32                 PASS      34.88 seconds
Incremental Build with patchesPASS      45.99 seconds
TestRunner: Setup             PASS      609.88 seconds
TestRunner: l2cap-tester      PASS      16.01 seconds
TestRunner: bnep-tester       PASS      7.20 seconds
TestRunner: mgmt-tester       PASS      126.48 seconds
TestRunner: rfcomm-tester     PASS      9.17 seconds
TestRunner: sco-tester        PASS      9.29 seconds
TestRunner: smp-tester        PASS      9.19 seconds
TestRunner: userchan-tester   PASS      7.58 seconds

Details
##############################
Test: CheckPatch - FAIL - 0.93 seconds
Run checkpatch.pl script with rule in .checkpatch.conf
Bluetooth: hci_event: Fix HCI_EV_VENDOR max_len\WARNING:TYPO_SPELLING: 'supress' may be misspelled - perhaps 'suppress'? #83:
In addition to it this makes use of bt_dev_warn_ratelimited to supress

                                                               ^^^^^^^

total: 0 errors, 1 warnings, 0 checks, 19 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.

/github/workspace/src/12724153.patch has style problems, please review.

NOTE: Ignored message types: UNKNOWN_COMMIT_ID

NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.

---
Regards,
Linux Bluetooth

maintainer
#2 lore raw
In reply to Luiz Augusto von Dentz

Hi Luiz,

Quoted 11 lines

HCI_EV_VENDOR is in fact variable length since it acts as metaevent where a vendor can implement their own event sets.

In addition to it this makes use of bt_dev_warn_ratelimited to supress the amount of logging in case the event has more data than expected.

Fixes 3e54c5890c87 ("Bluetooth: hci_event: Use of a function table to handle HCI event")

---
net/bluetooth/hci_event.c | 7 ++++---

1 file changed, 4 insertions(+), 3 deletions(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel

author maintainer
#4 lore raw

Hi Mike,

Quoted 9 lines · Mike Lothian

Hi

I've only just noticed this patch solves my issue

https://lore.kernel.org/netdev/[email protected]/

Can it be added to stable too?

Quoted 7 lines

My patch can then be ignored:

https://patchwork.kernel.org/project/bluetooth/patch/[email protected]/

Thanks

Mike

We fixed this a while back:

https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git/commit/net/bluetooth/hci_event.c?id=314d8cd2787418c5ac6b02035c344644f47b292b

Signature · 1 line
Luiz Augusto von Dentz
author maintainer
#6 lore raw

Hi Marcel,

Quoted 7 lines · Mike Lothian
Quoted 4 lines · Luiz Augusto von Dentz

We fixed this a while back:

Quoted 9 lines
Quoted 4 lines

https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git/commit/net/bluetooth/hci_event.c?id=314d8cd2787418c5ac6b02035c344644f47b292b

--
Luiz Augusto von Dentz

Yes, and it looks like that commit is queued for kernel 5.18. I was hoping you could get it added into 5.17 where I'm seeing spurious messages during boot, before it's released

Can we perhaps merge it to bluetooth.git so we send a pr to be included in 5.17?

Signature · 1 line
Luiz Augusto von Dentz