2022-01-26 06:34:54

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: [PATCH] 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")
Signed-off-by: Luiz Augusto von Dentz <[email protected]>
---
net/bluetooth/hci_event.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 664ccf1d8d93..63b925921c87 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -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)
--
2.34.1


2022-01-26 08:34:25

by bluez.test.bot

[permalink] [raw]
Subject: RE: Bluetooth: hci_event: Fix HCI_EV_VENDOR max_len

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

2022-01-26 10:01:31

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [PATCH] Bluetooth: hci_event: Fix HCI_EV_VENDOR max_len

Hi Luiz,

> 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")
> Signed-off-by: Luiz Augusto von Dentz <[email protected]>
> ---
> net/bluetooth/hci_event.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel

2022-03-14 14:54:08

by Mike Lothian

[permalink] [raw]
Subject: Re: [PATCH] Bluetooth: hci_event: Fix HCI_EV_VENDOR max_len

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?

My patch can then be ignored:

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

Thanks

Mike

2022-03-15 00:51:58

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [PATCH] Bluetooth: hci_event: Fix HCI_EV_VENDOR max_len

Hi Marcel,

On Mon, Mar 14, 2022 at 11:31 AM Mike Lothian <[email protected]> wrote:
>
> On Mon, 14 Mar 2022 at 17:30, Luiz Augusto von Dentz
> <[email protected]> wrote:
> >
> >
> > 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
> >
> > --
> > 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?


--
Luiz Augusto von Dentz

2022-03-15 15:23:56

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [PATCH] Bluetooth: hci_event: Fix HCI_EV_VENDOR max_len

Hi Mike,

On Mon, Mar 14, 2022 at 6:50 AM Mike Lothian <[email protected]> wrote:
>
> 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?
>
> 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

--
Luiz Augusto von Dentz

2022-03-16 08:45:07

by Mike Lothian

[permalink] [raw]
Subject: Re: [PATCH] Bluetooth: hci_event: Fix HCI_EV_VENDOR max_len

On Mon, 14 Mar 2022 at 17:30, Luiz Augusto von Dentz
<[email protected]> wrote:
>
>
> 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
>
> --
> 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

Thanks

Mike