* [PATCH v1] Bluetooth: btmtk: add event filter to filter specific event
@ 2026-04-07 6:47 Chris Lu
2026-04-07 7:14 ` Paul Menzel
0 siblings, 1 reply; 3+ messages in thread
From: Chris Lu @ 2026-04-07 6:47 UTC (permalink / raw)
To: Marcel Holtmann, Johan Hedberg, Luiz Von Dentz
Cc: Sean Wang, Will Lee, SS Wu, Steve Lee, linux-bluetooth,
linux-kernel, linux-mediatek, Chris Lu
Due to some Bluetooth hosts have mechanism to detect invalid events,
causing abnormal behavior. Add a event filter to prevent debugging
events from being sent to host.
Signed-off-by: Chris Lu <chris.lu@mediatek.com>
---
drivers/bluetooth/btmtk.c | 22 ++++++++++++++++++++++
drivers/bluetooth/btmtk.h | 7 +++++++
drivers/bluetooth/btusb.c | 2 ++
3 files changed, 31 insertions(+)
diff --git a/drivers/bluetooth/btmtk.c b/drivers/bluetooth/btmtk.c
index 55516b4602db..302d6ddf9062 100644
--- a/drivers/bluetooth/btmtk.c
+++ b/drivers/bluetooth/btmtk.c
@@ -1503,6 +1503,28 @@ int btmtk_usb_shutdown(struct hci_dev *hdev)
return 0;
}
EXPORT_SYMBOL_GPL(btmtk_usb_shutdown);
+
+int btmtk_recv_event(struct hci_dev *hdev, struct sk_buff *skb)
+{
+ struct hci_event_hdr *hdr = (void *)skb->data;
+
+ if (hdr->evt == HCI_EV_CMD_COMPLETE) {
+ struct hci_ev_cmd_complete *ec;
+ u16 opcode;
+
+ ec = (void *)(skb->data + HCI_EVENT_HDR_SIZE);
+ opcode = __le16_to_cpu(ec->opcode);
+
+ /* Filter vendor opcode */
+ if (opcode == 0xfc5d) {
+ kfree_skb(skb);
+ return 0;
+ }
+ }
+
+ return hci_recv_frame(hdev, skb);
+}
+EXPORT_SYMBOL_GPL(btmtk_recv_event);
#endif
MODULE_AUTHOR("Sean Wang <sean.wang@mediatek.com>");
diff --git a/drivers/bluetooth/btmtk.h b/drivers/bluetooth/btmtk.h
index adaf385626ee..08b73927c8f3 100644
--- a/drivers/bluetooth/btmtk.h
+++ b/drivers/bluetooth/btmtk.h
@@ -218,6 +218,8 @@ int btmtk_usb_suspend(struct hci_dev *hdev);
int btmtk_usb_setup(struct hci_dev *hdev);
int btmtk_usb_shutdown(struct hci_dev *hdev);
+
+int btmtk_recv_event(struct hci_dev *hdev, struct sk_buff *skb);
#else
static inline int btmtk_set_bdaddr(struct hci_dev *hdev,
@@ -296,4 +298,9 @@ static inline int btmtk_usb_shutdown(struct hci_dev *hdev)
{
return -EOPNOTSUPP;
}
+
+static inline int btmtk_recv_event(struct hci_dev *hdev, struct sk_buff *skb)
+{
+ return -EOPNOTSUPP;
+}
#endif
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index f9d515ee9124..daf8a387e660 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -4150,6 +4150,8 @@ static int btusb_probe(struct usb_interface *intf,
} else if (id->driver_info & BTUSB_MEDIATEK) {
/* Allocate extra space for Mediatek device */
priv_size += sizeof(struct btmtk_data);
+
+ data->recv_event = btmtk_recv_event;
}
data->recv_acl = hci_recv_frame;
--
2.45.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v1] Bluetooth: btmtk: add event filter to filter specific event
2026-04-07 6:47 [PATCH v1] Bluetooth: btmtk: add event filter to filter specific event Chris Lu
@ 2026-04-07 7:14 ` Paul Menzel
2026-04-07 10:34 ` Chris Lu (陸稚泓)
0 siblings, 1 reply; 3+ messages in thread
From: Paul Menzel @ 2026-04-07 7:14 UTC (permalink / raw)
To: Chris Lu
Cc: Marcel Holtmann, Johan Hedberg, Luiz Von Dentz, Sean Wang,
Will Lee, SS Wu, Steve Lee, linux-bluetooth, LKML, linux-mediatek
Dear Chris,
Thank you for the patch.
Am 07.04.26 um 08:47 schrieb Chris Lu:
> Due to some Bluetooth hosts have mechanism to detect invalid events,
> causing abnormal behavior.
Sorry, this description is much too short and general. Please elaborate,
and document details.
> Add a event filter to prevent debugging events from being sent to host.
a*n*
What are debugging events, and how can they be detected?
> Signed-off-by: Chris Lu <chris.lu@mediatek.com>
Should there be a Fixes: tag, so it gets backported?
> ---
> drivers/bluetooth/btmtk.c | 22 ++++++++++++++++++++++
> drivers/bluetooth/btmtk.h | 7 +++++++
> drivers/bluetooth/btusb.c | 2 ++
> 3 files changed, 31 insertions(+)
>
> diff --git a/drivers/bluetooth/btmtk.c b/drivers/bluetooth/btmtk.c
> index 55516b4602db..302d6ddf9062 100644
> --- a/drivers/bluetooth/btmtk.c
> +++ b/drivers/bluetooth/btmtk.c
> @@ -1503,6 +1503,28 @@ int btmtk_usb_shutdown(struct hci_dev *hdev)
> return 0;
> }
> EXPORT_SYMBOL_GPL(btmtk_usb_shutdown);
> +
> +int btmtk_recv_event(struct hci_dev *hdev, struct sk_buff *skb)
> +{
> + struct hci_event_hdr *hdr = (void *)skb->data;
> +
> + if (hdr->evt == HCI_EV_CMD_COMPLETE) {
> + struct hci_ev_cmd_complete *ec;
> + u16 opcode;
> +
> + ec = (void *)(skb->data + HCI_EVENT_HDR_SIZE);
> + opcode = __le16_to_cpu(ec->opcode);
> +
> + /* Filter vendor opcode */
> + if (opcode == 0xfc5d) {
> + kfree_skb(skb);
> + return 0;
> + }
> + }
> +
> + return hci_recv_frame(hdev, skb);
> +}
> +EXPORT_SYMBOL_GPL(btmtk_recv_event);
> #endif
>
> MODULE_AUTHOR("Sean Wang <sean.wang@mediatek.com>");
> diff --git a/drivers/bluetooth/btmtk.h b/drivers/bluetooth/btmtk.h
> index adaf385626ee..08b73927c8f3 100644
> --- a/drivers/bluetooth/btmtk.h
> +++ b/drivers/bluetooth/btmtk.h
> @@ -218,6 +218,8 @@ int btmtk_usb_suspend(struct hci_dev *hdev);
> int btmtk_usb_setup(struct hci_dev *hdev);
>
> int btmtk_usb_shutdown(struct hci_dev *hdev);
> +
> +int btmtk_recv_event(struct hci_dev *hdev, struct sk_buff *skb);
> #else
>
> static inline int btmtk_set_bdaddr(struct hci_dev *hdev,
> @@ -296,4 +298,9 @@ static inline int btmtk_usb_shutdown(struct hci_dev *hdev)
> {
> return -EOPNOTSUPP;
> }
> +
> +static inline int btmtk_recv_event(struct hci_dev *hdev, struct sk_buff *skb)
> +{
> + return -EOPNOTSUPP;
> +}
> #endif
> diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
> index f9d515ee9124..daf8a387e660 100644
> --- a/drivers/bluetooth/btusb.c
> +++ b/drivers/bluetooth/btusb.c
> @@ -4150,6 +4150,8 @@ static int btusb_probe(struct usb_interface *intf,
> } else if (id->driver_info & BTUSB_MEDIATEK) {
> /* Allocate extra space for Mediatek device */
> priv_size += sizeof(struct btmtk_data);
> +
> + data->recv_event = btmtk_recv_event;
> }
>
> data->recv_acl = hci_recv_frame;
Kind regards,
Paul
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v1] Bluetooth: btmtk: add event filter to filter specific event
2026-04-07 7:14 ` Paul Menzel
@ 2026-04-07 10:34 ` Chris Lu (陸稚泓)
0 siblings, 0 replies; 3+ messages in thread
From: Chris Lu (陸稚泓) @ 2026-04-07 10:34 UTC (permalink / raw)
To: pmenzel@molgen.mpg.de
Cc: Will-CY Lee (李政穎),
Steve Lee (李視誠), luiz.dentz@gmail.com,
marcel@holtmann.org, SS Wu (巫憲欣),
linux-kernel@vger.kernel.org, johan.hedberg@gmail.com, Sean Wang,
linux-bluetooth@vger.kernel.org,
linux-mediatek@lists.infradead.org
Dear Paul,
On Tue, 2026-04-07 at 09:14 +0200, Paul Menzel wrote:
>
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
>
>
> Dear Chris,
>
>
> Thank you for the patch.
>
> Am 07.04.26 um 08:47 schrieb Chris Lu:
> > Due to some Bluetooth hosts have mechanism to detect invalid
> > events,
> > causing abnormal behavior.
>
> Sorry, this description is much too short and general. Please
> elaborate,
> and document details.
>
> > Add a event filter to prevent debugging events from being sent to
> > host.
>
> a*n*
>
> What are debugging events, and how can they be detected?
Thanks for your suggestion.
I'll submit v2 to revise the commit message to avoid using vague
descriptions.
>
> > Signed-off-by: Chris Lu <chris.lu@mediatek.com>
>
> Should there be a Fixes: tag, so it gets backported?
No, it's not an issue derived from previous driver changes.
>
> > ---
> > drivers/bluetooth/btmtk.c | 22 ++++++++++++++++++++++
> > drivers/bluetooth/btmtk.h | 7 +++++++
> > drivers/bluetooth/btusb.c | 2 ++
> > 3 files changed, 31 insertions(+)
> >
> > diff --git a/drivers/bluetooth/btmtk.c b/drivers/bluetooth/btmtk.c
> > index 55516b4602db..302d6ddf9062 100644
> > --- a/drivers/bluetooth/btmtk.c
> > +++ b/drivers/bluetooth/btmtk.c
> > @@ -1503,6 +1503,28 @@ int btmtk_usb_shutdown(struct hci_dev *hdev)
> > return 0;
> > }
> > EXPORT_SYMBOL_GPL(btmtk_usb_shutdown);
> > +
> > +int btmtk_recv_event(struct hci_dev *hdev, struct sk_buff *skb)
> > +{
> > + struct hci_event_hdr *hdr = (void *)skb->data;
> > +
> > + if (hdr->evt == HCI_EV_CMD_COMPLETE) {
> > + struct hci_ev_cmd_complete *ec;
> > + u16 opcode;
> > +
> > + ec = (void *)(skb->data + HCI_EVENT_HDR_SIZE);
> > + opcode = __le16_to_cpu(ec->opcode);
> > +
> > + /* Filter vendor opcode */
> > + if (opcode == 0xfc5d) {
> > + kfree_skb(skb);
> > + return 0;
> > + }
> > + }
> > +
> > + return hci_recv_frame(hdev, skb);
> > +}
> > +EXPORT_SYMBOL_GPL(btmtk_recv_event);
> > #endif
> >
> > MODULE_AUTHOR("Sean Wang <sean.wang@mediatek.com>");
> > diff --git a/drivers/bluetooth/btmtk.h b/drivers/bluetooth/btmtk.h
> > index adaf385626ee..08b73927c8f3 100644
> > --- a/drivers/bluetooth/btmtk.h
> > +++ b/drivers/bluetooth/btmtk.h
> > @@ -218,6 +218,8 @@ int btmtk_usb_suspend(struct hci_dev *hdev);
> > int btmtk_usb_setup(struct hci_dev *hdev);
> >
> > int btmtk_usb_shutdown(struct hci_dev *hdev);
> > +
> > +int btmtk_recv_event(struct hci_dev *hdev, struct sk_buff *skb);
> > #else
> >
> > static inline int btmtk_set_bdaddr(struct hci_dev *hdev,
> > @@ -296,4 +298,9 @@ static inline int btmtk_usb_shutdown(struct
> > hci_dev *hdev)
> > {
> > return -EOPNOTSUPP;
> > }
> > +
> > +static inline int btmtk_recv_event(struct hci_dev *hdev, struct
> > sk_buff *skb)
> > +{
> > + return -EOPNOTSUPP;
> > +}
> > #endif
> > diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
> > index f9d515ee9124..daf8a387e660 100644
> > --- a/drivers/bluetooth/btusb.c
> > +++ b/drivers/bluetooth/btusb.c
> > @@ -4150,6 +4150,8 @@ static int btusb_probe(struct usb_interface
> > *intf,
> > } else if (id->driver_info & BTUSB_MEDIATEK) {
> > /* Allocate extra space for Mediatek device */
> > priv_size += sizeof(struct btmtk_data);
> > +
> > + data->recv_event = btmtk_recv_event;
> > }
> >
> > data->recv_acl = hci_recv_frame;
>
>
> Kind regards,
>
> Paul
Thanks,
Chris Lu
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-04-07 10:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-07 6:47 [PATCH v1] Bluetooth: btmtk: add event filter to filter specific event Chris Lu
2026-04-07 7:14 ` Paul Menzel
2026-04-07 10:34 ` Chris Lu (陸稚泓)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox