All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 1/6] Bluetooth: L2CAP: Reject mode changes on connected channels
@ 2026-10-13 15:36 Siwei Zhang
  2026-10-13 15:36 ` [PATCH v4 2/6] Bluetooth: L2CAP: Reject signalling responses in invalid states Siwei Zhang
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Siwei Zhang @ 2026-10-13 15:36 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth, Siwei Zhang

A peer can send a configuration response with an RFC
option for another mode to a connected channel, for
example to switch it from Streaming to ERTM mode.
l2cap_parse_conf_rsp() then changes chan->mode, but
l2cap_ertm_init() is not called again, so the ERTM
sequence lists are never allocated. The next
out-of-sequence I-frame makes l2cap_seq_list_clear()
write through the NULL srej_list.list.

Refuse the channel when a response tries to change
the mode of a connected channel.

Fixes: f2fcfcd67025 ("Bluetooth: Add configuration support for ERTM and Streaming mode")
Cc: stable@vger.kernel.org
Closes: https://sashiko.dev/#/patchset/20261007144717.3832330-1-oss%40fourdim.xyz
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Siwei Zhang <oss@fourdim.xyz>
---
v2:
  - assemble the patch series
v1: https://lore.kernel.org/linux-bluetooth/20261008141714.95709-1-oss@fourdim.xyz/

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

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 49a998804908..c730da87734b 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -3876,7 +3876,11 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
 		}
 	}
 
-	if (chan->mode == L2CAP_MODE_BASIC && chan->mode != rfc.mode)
+	/* A connected channel cannot change its mode, as the new mode would
+	 * not be initialized.
+	 */
+	if (chan->mode != rfc.mode &&
+	    (chan->mode == L2CAP_MODE_BASIC || chan->state == BT_CONNECTED))
 		return -ECONNREFUSED;
 
 	chan->mode = rfc.mode;
-- 
2.55.0


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

end of thread, other threads:[~2026-10-14 17:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-13 15:36 [PATCH v4 1/6] Bluetooth: L2CAP: Reject mode changes on connected channels Siwei Zhang
2026-10-13 15:36 ` [PATCH v4 2/6] Bluetooth: L2CAP: Reject signalling responses in invalid states Siwei Zhang
2026-10-13 15:36 ` [PATCH v4 3/6] Bluetooth: L2CAP: Reject invalid TxWindow in configuration requests Siwei Zhang
2026-10-13 15:36 ` [PATCH v4 4/6] Bluetooth: L2CAP: Use default TxWindow for zero socket option Siwei Zhang
2026-10-13 15:36 ` [PATCH v4 5/6] Bluetooth: L2CAP: Only accept connection responses to outstanding requests Siwei Zhang
2026-10-13 15:36 ` [PATCH v4 6/6] Bluetooth: L2CAP: Remove dead configuration state code Siwei Zhang
2026-10-13 20:18 ` [v4,1/6] Bluetooth: L2CAP: Reject mode changes on connected channels bluez.test.bot
2026-10-14 17:20 ` [PATCH v4 1/6] " patchwork-bot+bluetooth

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.