diff mbox series

Bluetooth: hci_event: Fix HCI_EV_VENDOR max_len

Message ID 20220125185305.2419774-1-luiz.dentz@gmail.com
State New
Headers show
Series Bluetooth: hci_event: Fix HCI_EV_VENDOR max_len | expand

Commit Message

Luiz Augusto von Dentz Jan. 25, 2022, 6:53 p.m. UTC
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

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 <luiz.von.dentz@intel.com>
---
 net/bluetooth/hci_event.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Mike Lothian March 14, 2022, 1:50 p.m. UTC | #1
Hi

I've only just noticed this patch solves my issue

https://lore.kernel.org/netdev/20220125144639.2226-1-mike@fireburn.co.uk/

Can it be added to stable too?

My patch can then be ignored:

https://patchwork.kernel.org/project/bluetooth/patch/20220312164550.1810665-1-mike@fireburn.co.uk/

Thanks

Mike
Luiz Augusto von Dentz March 14, 2022, 5:30 p.m. UTC | #2
Hi Mike,

On Mon, Mar 14, 2022 at 6:50 AM Mike Lothian <mike@fireburn.co.uk> wrote:
>
> Hi
>
> I've only just noticed this patch solves my issue
>
> https://lore.kernel.org/netdev/20220125144639.2226-1-mike@fireburn.co.uk/
>
> Can it be added to stable too?
>
> My patch can then be ignored:
>
> https://patchwork.kernel.org/project/bluetooth/patch/20220312164550.1810665-1-mike@fireburn.co.uk/
>
> 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
Mike Lothian March 14, 2022, 6:31 p.m. UTC | #3
On Mon, 14 Mar 2022 at 17:30, Luiz Augusto von Dentz
<luiz.dentz@gmail.com> 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
Luiz Augusto von Dentz March 14, 2022, 8:09 p.m. UTC | #4
Hi Marcel,

On Mon, Mar 14, 2022 at 11:31 AM Mike Lothian <mike@fireburn.co.uk> wrote:
>
> On Mon, 14 Mar 2022 at 17:30, Luiz Augusto von Dentz
> <luiz.dentz@gmail.com> 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?
diff mbox series

Patch

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)