Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: msft: Ignore vendor events shorter than the event prefix
@ 2026-10-10 14:08 Adrian.Nguyen-Qualgo
  2026-10-10 15:30 ` bluez.test.bot
  2026-10-10 15:51 ` [PATCH] " Alexey Minnekhanov
  0 siblings, 2 replies; 3+ messages in thread
From: Adrian.Nguyen-Qualgo @ 2026-10-10 14:08 UTC (permalink / raw)
  To: Marcel Holtmann, Luiz Augusto von Dentz
  Cc: linux-bluetooth, linux-kernel, Adrian Nguyen

From: Adrian Nguyen <thenguyen1024@gmail.com>

msft_vendor_evt() is called for every HCI vendor event. When the
controller defines an MSFT event prefix, it pulls the prefix with
msft_skb_pull(), which logs "Malformed MSFT vendor event" when the
event is too short. A vendor event shorter than the prefix cannot be
an MSFT event, though, so it is reported as malformed for nothing.
Before commit 3368aa357f3b ("Bluetooth: msft: Handle MSFT Monitor
Device Event") such events were dropped silently.

A WCN3990 logs this 20 times at every boot, while btqca downloads its
firmware and the controller answers each segment with a short QCA
vendor event.

Return quietly when the event is shorter than the prefix. Events that
match the prefix but are cut short still get reported.

Fixes: 3368aa357f3b ("Bluetooth: msft: Handle MSFT Monitor Device Event")
Assisted-by: LLM
Signed-off-by: Adrian Nguyen <thenguyen1024@gmail.com>
---

Notes:
    An LLM helped track down the cause and draft the fix and changelog;
    I reviewed the result and tested it.
    
    Tested on a Vsmart Active 1 (SDM660, WCN3990) with a 7.2-based kernel:
    the errors are gone at boot and hci0 comes up as before. Build-tested
    on bluetooth-next with W=1.

 net/bluetooth/msft.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/net/bluetooth/msft.c b/net/bluetooth/msft.c
index 6f4b7c38a247..a3f07f35a1b3 100644
--- a/net/bluetooth/msft.c
+++ b/net/bluetooth/msft.c
@@ -1082,9 +1082,13 @@ void msft_vendor_evt(struct hci_dev *hdev, void *data, struct sk_buff *skb)
 		return;
 
 	/* When the extension has defined an event prefix, check that it
-	 * matches, and otherwise just return.
+	 * matches, and otherwise just return. A vendor event shorter than the
+	 * prefix cannot be an MSFT event, so it is not malformed either.
 	 */
 	if (msft->evt_prefix_len > 0) {
+		if (skb->len < msft->evt_prefix_len)
+			return;
+
 		evt_prefix = msft_skb_pull(hdev, skb, 0, msft->evt_prefix_len);
 		if (!evt_prefix)
 			return;

base-commit: 964430c038967fd06643e866f68115664e1a1bd1
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-10 15:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-10 14:08 [PATCH] Bluetooth: msft: Ignore vendor events shorter than the event prefix Adrian.Nguyen-Qualgo
2026-10-10 15:30 ` bluez.test.bot
2026-10-10 15:51 ` [PATCH] " Alexey Minnekhanov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox