Skip to content

Bluetooth: L2CAP: Match LE responses to outstanding requests

Zhao Li linux-bluetooth lkml stable 1 version Applied

Status from this message: This series was applied to bluetooth/bluetooth-next.git (master)

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 2 repliesApplied 2/2

Patches in v1 All 2 applied

#Subject and filesSizeRepliesApplied
1/2Bluetooth: L2CAP: Only accept LE responses to outstanding requestsinclude/net/bluetooth/l2cap.h net/bluetooth/l2cap_core.c+42 -411 replyApplied
2/2Bluetooth: L2CAP: Clear request identifiers on incoming LE connectionsnet/bluetooth/l2cap_core.c+3 -21 replyApplied

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/2] Bluetooth: L2CAP: Match LE responses to outstanding requests

An LE peer that can reach a local L2CAP listener can use unsolicited responses or Command Rejects to bypass deferred setup, remove an established channel, or leak an unaccepted socket and channel. Authentication requirements depend on the listener's security setting; whether a default configuration exposes such a listener has not been checked.

Patch 1 requires an outstanding request of the matching kind before a response or reject can change a channel. It also completes socket cleanup when a reconfigure failure or reject arrives after local close. Patch 2 clears incoming identifiers once their responses have been sent, so a later ECRED request that reuses one no longer matches the old channel. Patch 1 is the security fix; patch 2 is separable.

Patch 1 extends the BR/EDR lookup from commit a518b9a9ef6e ("Bluetooth:
L2CAP: Only accept connection responses to outstanding requests"). Its stable tags request 5.7 and newer with that prerequisite or an equivalent backport. Older LE-only trees need an adapted backport without the ECRED hunks.

AI assistance was used.

GCC 12.2 and Clang 19.1.7 builds passed at W=1, including full x86_64 module linking after each patch. GCC also compiled the Bluetooth code built-in on x86_64 and as modules on i386. Sparse reported no diagnostic; Smatch retained its one pre-existing diagnostic. Coccinelle 1.3's use_after_iter rule found nothing in the changed functions; five unchanged parser gaps also occur in the base.

QEMU/vhci testing with patch 1 alone kept all 445 established channels alive. In 40-pair close-before runs, failed reconfigure responses and Command Rejects each destroyed about 40 sockets with the fix and only boot-noise sockets on the base. The success path destroyed the same number on both. A 1200-pair base run retained gross Slab memory after listener close while the fixed arms released it.

With patch 2, new ECRED requests that reused the identifier of a closing LE channel completed instead of being refused; partially accepted groups were not tested. A KCSAN kernel with both patches reported no data races in the close-before runs.

Hardware validation has not been run. Patch 1 does not apply to stable branches as is; adapted backports of both patches compiled at W=1 and linked as modules on the seven supported lines, and were not tested.

Zhao Li (2):
Bluetooth: L2CAP: Only accept LE responses to outstanding requests
Bluetooth: L2CAP: Clear request identifiers on incoming LE connections

 include/net/bluetooth/l2cap.h |  1 +
 net/bluetooth/l2cap_core.c    | 87 ++++++++++++++++++-----------------
 2 files changed, 45 insertions(+), 43 deletions(-)

base-commit: 6b4b543fa18757297ac756a6fe6e64f506b7844a

Signature · 1 line
2.56.0