Linux bluetooth development
 help / color / mirror / Atom feed
From: Kyle Pepper <cochcoder@proton.me>
To: linux-bluetooth@vger.kernel.org
Cc: luiz.dentz@gmail.com, marcel@holtmann.org, linux-kernel@vger.kernel.org
Subject: [PATCH v15 1/2] Bluetooth: L2CAP: Restrict LE credits to connected CoCs
Date: Mon, 30 Nov 2026 00:05:55 +0000	[thread overview]
Message-ID: <6aff9cb5ebb1f1512734d5ecdac876a2cc0c86bc.1795807576.git.github.filter194@slmail.me> (raw)
In-Reply-To: <6aff9cb5ebb1f1512734d5ecdac876a2cc0c86bc.1795650070.git.github.filter194@slmail.me>

Do not let credit indications change fixed channels or complete pending
connection setup. Validate the channel state and mode before accounting
credits, checking overflow or invoking its resume callback.

AI assistance: Codex prepared this attribution revision and assisted
with validation and commit text. Earlier revisions disclosed LLM
assistance for the credit-state guard.

Fixes: fad5fc89594d ("Bluetooth: Add LE flow control discipline")
Signed-off-by: Kyle Pepper <cochcoder@proton.me>
---
Local validation at mail preparation:
- GCC/Clang sanitizer models: 134 expected outcomes, plus two
  preceding-source comparisons.
- GCC/Clang/ECRED-off W=1 objects, sparse and strict CheckPatch pass.
  Smatch retains two inherited v14 diagnostics.
- KCSAN and KASAN guest reruns use a separate workqueue prerequisite:
  work_static() reads work->data through atomic_long_read(). This fixes
  the preserved strict KCSAN report against queue_work_on(). The
  prerequisite is outside this two-patch Bluetooth series; the four
  reviewed Bluetooth files match the submitted source hashes.
- KCSAN focused: 16/16; no kernel alerts.
- KCSAN full: 138/142; no kernel alerts. All remaining failures match preserved v14 failures. One prior timeout now passes.
- KASAN focused: 16/16; no kernel alerts.
- KASAN full: 137/142; no kernel alerts. All remaining failures match preserved v14 failures.
The private tester waits for old-channel failure dispatch before requiring
a new request to succeed. The earlier premature-admission test is preserved.
The isolated checks ran alongside a kernel package build while its
exclusive trial lock excluded hardware capture; they did not acquire
that lock or delay the package install handoff. Lock protection was
checked throughout. The original exact-match comparison rejected the
improved KCSAN case; its raw FAIL record remains preserved.
Strict KCSAN, weak-memory checks, lockdep and panic-on-warning remain
active. The unmodified base still has the preserved KCSAN failure.
Full validation remains incomplete. No v15 remote CI or hardware/PTS
result is claimed. Inherited suite failures and Smatch findings remain.

Changes in v15:
- Keep a security upgrade pending while SMP key distribution runs;
  complete or fail it when pairing ends (new l2cap_security_recheck()).
- Treat a latched SMP failure as failing every pending CoC upgrade
  before the work item marks them.
- Consume the ECONNREFUSED returned to a deferred reader so it is not
  reported twice.
- Reject BT_RCVMTU reconfiguration with EBUSY while a deferred ECRED
  response is unsent.
- Restore shared-link pending security and MIC requirements after the
  last pending upgrade, preserving achieved and surviving requirements;
  revisit restoration on encryption-only confirmations too.
- Acquire every distinct sibling's nested lock before batch completion;
  only the channel already locked by the caller skips acquisition (H1).
- Consume the whole rejected batch before teardown callbacks can revisit
  another member and send a duplicate response (H2).
- Patch 1's code and commit message are unchanged; only its mail version
  and series revision notes change.

Previous v14 (no cover letter):
https://lore.kernel.org/linux-bluetooth/6aff9cb5ebb1f1512734d5ecdac876a2cc0c86bc.1795650070.git.github.filter194@slmail.me/
Previous patch 2:
https://lore.kernel.org/linux-bluetooth/fc7072a78de49b72d9034349512983d95be4ba1a.1795650070.git.github.filter194@slmail.me/

V15 remote CI has not been run or verified. Local validation and limits
are recorded separately; these unsigned exports require human review
and DCO certification before sending.

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

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 943effc867402e232d4d4c4a93d4b7ba5d376367..8229bddca5df761dd1359b88752e3d5f6d6090cf 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -5469,6 +5469,11 @@ static inline int l2cap_le_credits(struct l2cap_conn *conn,
 
 	l2cap_chan_lock(chan);
 
+	if (chan->state != BT_CONNECTED ||
+	    (chan->mode != L2CAP_MODE_LE_FLOWCTL &&
+	     chan->mode != L2CAP_MODE_EXT_FLOWCTL))
+		goto unlock;
+
 	max_credits = LE_FLOWCTL_MAX_CREDITS - chan->tx_credits;
 	if (credits > max_credits) {
 		BT_ERR("LE credits overflow");

base-commit: f57f78086ab54f3b3122fbaeba2c842ba7bb6d00


  parent reply	other threads:[~2026-11-30  0:06 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13  3:06 [PATCH v10 1/2] Bluetooth: L2CAP: Restrict LE credits to connected CoCs Kyle Pepper
2026-11-13  3:06 ` [PATCH v10 2/2] Bluetooth: L2CAP: Keep credits from completing security upgrades Kyle Pepper
2026-11-13 14:00 ` [PATCH v11 1/2] Bluetooth: L2CAP: Restrict LE credits to connected CoCs Kyle Pepper
2026-11-13 17:10   ` [v11,1/2] " bluez.test.bot
2026-11-14  6:05   ` [PATCH v12 1/2] " Kyle Pepper
2026-11-24 14:02     ` [PATCH v13 " Kyle Pepper
2026-11-24 18:48       ` [v13,1/2] " bluez.test.bot
2026-11-25 23:44       ` [PATCH v14 1/2] " Kyle Pepper
2026-11-26  3:40         ` [v14,1/2] " bluez.test.bot
2026-11-30  0:05         ` Kyle Pepper [this message]
2026-11-30  0:06         ` [PATCH v15 2/2] Bluetooth: L2CAP: Keep credits from completing security upgrades Kyle Pepper
2026-11-25 23:44       ` [PATCH v14 " Kyle Pepper
2026-11-24 14:02     ` [PATCH v13 " Kyle Pepper
2026-11-14  6:05   ` [PATCH v12 " Kyle Pepper
2026-11-13 14:00 ` [PATCH v11 " Kyle Pepper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6aff9cb5ebb1f1512734d5ecdac876a2cc0c86bc.1795807576.git.github.filter194@slmail.me \
    --to=cochcoder@proton.me \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    --cc=marcel@holtmann.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox