public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: l2cap: Fix MPS check in l2cap_ecred_reconf_req
@ 2026-04-13  8:56 Dudu Lu
  2026-04-13  9:41 ` bluez.test.bot
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Dudu Lu @ 2026-04-13  8:56 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: marcel, luiz.dentz, Dudu Lu

The L2CAP Enhanced Credit Based Flow Control specification (Core Spec
5.4, Vol 3, Part A, Section 7.11) states that if more than one channel
is being reconfigured, the MPS shall not be decreased. The current code
uses `&& i` (loop index) to approximate "more than one channel", but
this incorrectly allows MPS decrease for the first channel (i==0) even
when multiple channels are being reconfigured, and incorrectly blocks
MPS decrease for subsequent channels even when only that single channel
is being reconfigured via index > 0.

Replace `&& i` with `&& num_scid > 1` which correctly checks whether
the reconfiguration request covers more than one channel, matching the
specification intent.

Signed-off-by: Dudu Lu <phx0fer@gmail.com>
---
 net/bluetooth/l2cap_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 95c65fece39b..b069f965a339 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -5428,7 +5428,7 @@ static inline int l2cap_ecred_reconf_req(struct l2cap_conn *conn,
 		 * configured, the MPS field may be less than the current MPS
 		 * of that channel.
 		 */
-		if (chan[i]->remote_mps >= mps && i) {
+		if (chan[i]->remote_mps >= mps && num_scid > 1) {
 			BT_ERR("chan %p decreased MPS %u -> %u", chan[i],
 			       chan[i]->remote_mps, mps);
 			result = L2CAP_RECONF_INVALID_MPS;
-- 
2.39.3 (Apple Git-145)


^ permalink raw reply related	[flat|nested] 6+ messages in thread
* [PATCH] Bluetooth: l2cap: fix MPS check in l2cap_ecred_reconf_req
@ 2026-04-15 10:43 Dudu Lu
  2026-04-15 21:00 ` patchwork-bot+bluetooth
  0 siblings, 1 reply; 6+ messages in thread
From: Dudu Lu @ 2026-04-15 10:43 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: marcel, luiz.dentz, Dudu Lu

The L2CAP specification states that if more than one channel is being
reconfigured, the MPS shall not be decreased. The current check has
two issues:

1) The comparison uses >= (greater-than-or-equal), which incorrectly
   rejects reconfiguration requests where the MPS stays the same.
   Since the spec says MPS "shall be greater than or equal to the
   current MPS", only a strict decrease (remote_mps > mps) should be
   rejected. Keeping the same MPS is valid.

2) The multi-channel guard uses `&& i` (loop index) to approximate
   "more than one channel", but this incorrectly allows MPS decrease
   for the first channel (i==0) even when multiple channels are being
   reconfigured. Replace with `&& num_scid > 1` which correctly
   checks whether the request covers more than one channel.

Signed-off-by: Dudu Lu <phx0fer@gmail.com>
---
 net/bluetooth/l2cap_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 95c65fece39b..29d793f3a2eb 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -5428,7 +5428,7 @@ static inline int l2cap_ecred_reconf_req(struct l2cap_conn *conn,
 		 * configured, the MPS field may be less than the current MPS
 		 * of that channel.
 		 */
-		if (chan[i]->remote_mps >= mps && i) {
+		if (chan[i]->remote_mps > mps && num_scid > 1) {
 			BT_ERR("chan %p decreased MPS %u -> %u", chan[i],
 			       chan[i]->remote_mps, mps);
 			result = L2CAP_RECONF_INVALID_MPS;
-- 
2.39.3 (Apple Git-145)


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

end of thread, other threads:[~2026-04-15 21:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-13  8:56 [PATCH] Bluetooth: l2cap: Fix MPS check in l2cap_ecred_reconf_req Dudu Lu
2026-04-13  9:41 ` bluez.test.bot
2026-04-13 17:16 ` [PATCH] " Luiz Augusto von Dentz
2026-04-13 21:02 ` bluez.test.bot
  -- strict thread matches above, loose matches on Subject: below --
2026-04-15 10:43 [PATCH] Bluetooth: l2cap: fix " Dudu Lu
2026-04-15 21:00 ` patchwork-bot+bluetooth

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