Skip to contentSkip to conversation

Bluetooth: L2CAP: reject BR/EDR signaling packets over MTUsig

PATCH Superseded Michael Bommarito 3 participants 5 messages May 21

Subsystems (5)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 Bluetooth: L2CAP: reject BR/EDR signaling packets over MTUsig

net/bluetooth/l2cap_core.c:l2cap_sig_channel() accepts BR/EDR signaling packets up to the channel MTU and dispatches each command without enforcing the signaling MTU (MTUsig). A Bluetooth BR/EDR peer within radio range can send a fixed-channel CID 0x0001 packet that is larger than MTUsig and contains many L2CAP_ECHO_REQ commands before pairing. In a real-radio stock-kernel run, one 681-byte signaling packet containing 168 zero-length ECHO_REQ commands made the target transmit 168 ECHO_RSP frames over about 220 ms.

Impact: a Bluetooth BR/EDR peer within radio range, before pairing, can force 168 ECHO_RSP frames from one 681-byte fixed-channel signaling packet containing packed ECHO_REQ commands.

Define Linux's BR/EDR signaling MTU as the spec minimum of 48 bytes and reject any larger signaling packet with one L2CAP_COMMAND_REJECT_RSP carrying L2CAP_REJ_MTU_EXCEEDED before any command is dispatched.

The Bluetooth Core spec wording for MTUExceeded says the reject identifier shall match the first request command in the packet, and that packets containing only responses shall be silently discarded. Linux intentionally deviates from that prescription: silently discarding desynchronizes the peer because the remote stack never learns its responses were dropped, and locating the first request command requires walking command headers past MTUsig, i.e. processing bytes from a packet we have already decided is too large to process. We therefore always emit one reject and use the identifier from the first command header (a single fixed-offset byte read), falling back to zero when the packet is too short to carry a header at all.

The unrestricted BR/EDR signaling parser and ECHO_REQ response path both trace to the initial git import; no later introducing commit is available for a Fixes tag.

---
Resending as top level message per netdev guidance.

I reproduced the stock behavior with a real-radio BR/EDR ACL link and a harness that sends a single fixed-channel signaling packet containing packed zero-length ECHO_REQ commands, and confirmed on a patched kernel that the same packet now produces one L2CAP_REJ_MTU_EXCEEDED command reject and zero ECHO_RSP frames. The patched code builds for net/bluetooth/l2cap_core.o on x86_64 defconfig with W=1. There are no in-tree Bluetooth selftests that reference l2cap_sig_channel(), L2CAP_SIG_MTU, or L2CAP_ECHO_REQ.

Changes in v3:
- Drop l2cap_sig_cmd_is_req() and l2cap_sig_first_req_ident(); the reject is now unconditional and uses only the first command header's identifier byte at a fixed offset. Per Luiz, the spec's "match the first request command identifier" rule would require parsing past MTUsig, and the spec's "silently discard if only responses" rule desynchronizes the peer.
- Replace the v2 walk with a verbose comment quoting the relevant Bluetooth Core section and documenting why Linux deviates.

Changes in v2:
- Replace the per-PDU echo-count cap with the MTUsig direction from review.
- Reject the whole over-MTUsig signaling packet with one L2CAP_REJ_MTU_EXCEEDED command reject.
- Add L2CAP_SIG_MTU and drop over-MTUsig packets when no valid request command identifier is found.

v1: https://lore.kernel.org/r/[email protected]
v2: https://lore.kernel.org/r/[email protected]

---
 include/net/bluetooth/l2cap.h |  1 +
 net/bluetooth/l2cap_core.c    | 47 +++++++++++++++++++++++++++++++++++
 2 files changed, 48 insertions(+)
include/net/bluetooth/l2cap.h +1 -0
index 5172afee54943..e0a1f2293679a 100644
@@ -33,6 +33,7 @@
 /* L2CAP defaults */
 #define L2CAP_DEFAULT_MTU		672
 #define L2CAP_DEFAULT_MIN_MTU		48
+#define L2CAP_SIG_MTU			48	/* BR/EDR signaling MTU */
 #define L2CAP_DEFAULT_FLUSH_TO		0xFFFF
 #define L2CAP_EFS_DEFAULT_FLUSH_TO	0xFFFFFFFF
 #define L2CAP_DEFAULT_TX_WINDOW		63
net/bluetooth/l2cap_core.c +47 -0

59 lines not on this page · raw message

Signature · 1 line
2.53.0
maintainer
#1 lore raw
Quoted 1 line · On Wed, 20 May 2026 20:13:27 -0400 Michael Bommarito wrote:

From: Michael Bommarito <[email protected]>

Please (tell your bot to) use the get_maintainer script.

#2 lore raw
Quoted 1 line · Jakub Kicinski

Please (tell your bot to) use the get_maintainer script.

It (and I) did, but I think this is because net/bluetooth/ matches net/, right?

Here's what I see when I run it. Is there a different set of args that I should be using for netdev or net/bluetooth/ in particular?

Marcel Holtmann <[email protected]> (maintainer:BLUETOOTH SUBSYSTEM) Luiz Augusto von Dentz <[email protected]> (maintainer:BLUETOOTH SUBSYSTEM) "David S. Miller" <[email protected]> (maintainer:NETWORKING [GENERAL]) Eric Dumazet <[email protected]> (maintainer:NETWORKING [GENERAL]) Jakub Kicinski <[email protected]> (maintainer:NETWORKING [GENERAL]) Paolo Abeni <[email protected]> (maintainer:NETWORKING [GENERAL]) Simon Horman <[email protected]> (reviewer:NETWORKING [GENERAL]) [email protected] (open list:BLUETOOTH SUBSYSTEM) [email protected] (open list:NETWORKING [GENERAL]) [email protected] (open list)

Or did you mean because of Fixes:? This dates back to original git import commit, so I thought the practice is to skip a Fixes: tag

Thanks,
Mike

maintainer
#3 lore raw
Quoted 4 lines · On Wed, 20 May 2026 20:32:28 -0400 Michael Bommarito wrote:
Quoted 1 line · Jakub Kicinski

Please (tell your bot to) use the get_maintainer script.

It (and I) did, but I think this is because net/bluetooth/ matches net/, right?

Looks like we're missing an X, sorry.

#4 lore raw
In reply to Michael Bommarito

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

---Test result---

Test Summary:

CheckPatch                    FAIL      1.00 seconds
GitLint                       FAIL      0.34 seconds
SubjectPrefix                 PASS      0.13 seconds
BuildKernel                   PASS      25.25 seconds
CheckAllWarning               PASS      28.83 seconds
CheckSparse                   PASS      27.41 seconds
BuildKernel32                 PASS      25.53 seconds
TestRunnerSetup               PASS      526.88 seconds
TestRunner_l2cap-tester       PASS      376.33 seconds
IncrementalBuild              PASS      24.88 seconds

Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script
Output:
[v3] Bluetooth: L2CAP: reject BR/EDR signaling packets over MTUsig
WARNING: The commit message has 'stable@', perhaps it also needs a 'Fixes:' tag?

total: 0 errors, 1 warnings, 0 checks, 66 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/patch/14585530.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.

##############################
Test: GitLint - FAIL
Desc: Run gitlint
Output:
[v3] Bluetooth: L2CAP: reject BR/EDR signaling packets over MTUsig

WARNING: I3 - ignore-body-lines: gitlint will be switching from using Python regex 'match' (match beginning) to 'search' (match anywhere) semantics. Please review your ignore-body-lines.regex option accordingly. To remove this warning, set general.regex-style-search=True. More details: https://jorisroovers.github.io/gitlint/configuration/#regex-style-search
38: B1 Line exceeds max length (84>80): "Link: https://lore.kernel.org/r/[email protected]"
39: B1 Line exceeds max length (84>80): "Link: https://lore.kernel.org/r/[email protected]"
73: B1 Line exceeds max length (82>80): "v1: https://lore.kernel.org/r/[email protected]"
74: B1 Line exceeds max length (82>80): "v2: https://lore.kernel.org/r/[email protected]"

https://github.com/bluez/bluetooth-next/pull/225

---
Regards,
Linux Bluetooth