From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.181 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796321654; b=0PtpqFZ04itenbOzb0G+W/CzAXIZeqqrRqPEGvs+BVZoLPoWgp1J2RSTC0KWPjBz+Ueb DJ+npgzemfgWmfhYEvsJZuj1PohMtodHUrzIMGJ22mGPMTF4E9yP7nax7nkOfMkcemo+D /qkJ7dZeM/MUTWzLWGTYJTwlMLW36JDKH8E82hngcXioojL1rnMh/Yf6L2GYgS0RCktG3 i8OLyc+YKw7d9ZRql02mAHYGf2WT5Uqw5Q4aO94I3RqQKV6hQNETyqSjdxB/DZGSgEgv1 3DKqy/zYEf3TbvDvqILg9PJRsPCymI7i9+qcVa+b4CRfL79qneiz20MJLwPUEaxmFmQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796321654; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Subject:Date: Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=SEaUxn79TCL9Ge2RAskhq69MW9cK805ksQSL3CjI4FA=; b=3XiQJC8okUvI5WtBzIsI/7LaUwLj9By4SSM/dhs8ORun2+4JerRsqvsNWJKrM3RB7LSN FnJU4P0cwpMuB/ptCwo9142mtdqBPh6YHyZ3SK9f8a8jlsJ20T+wFjeM6A/F3Jx32pQBB CkC+Fmrmvwb9uB1Yvz7w93to4PZxH0pJBcvhK8qz5QQ6lPCou+qPWleNtAe1BIWZueliq uW8hw/hAIWz0k2HpUI/Cw/Ag57nk8V4NZn7HzuwETDC1StkC7pwYvlSJhjN4vQKt5HS78 fEuPp3JSpQdcmzwZPapCN770+JUMczp2F1sEH6BsZf4qqPDDQo18JxntPuyCc/FTMpg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=xv7SeI8c; arc=none smtp.remote-ip=209.85.221.181 Received: from mail-vk1-f181.google.com (mail-vk1-f181.google.com [209.85.221.181]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9881C606A32D for ; Thu, 3 Dec 2026 18:14:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9881C606A32D Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=xv7SeI8c Received: by mail-vk1-f181.google.com with SMTP id 71dfb90a1353d-5ea969fafeeso9126e0c.0 for ; Thu, 03 Dec 2026 10:14:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796321652; x=1796926452; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=SEaUxn79TCL9Ge2RAskhq69MW9cK805ksQSL3CjI4FA=; b=xv7SeI8cACJZzW+aZVpxBTKTAho7DHAW4zz3MN1ulolShp59ZZjvmczEvLlmlB5ePx un666SOaGnKXJmpxOmDAuOxpVnfNeC1WUIS81eo12goAirsKFzruTVYdjv774KOofZaL RVlx2ExcuFFjUmrsQRmsS7hw7dDm9ICvaI6M++mtB9nwXXs6+MyXxsS11e2phJOeDwra MxqWTJd5ZwfDyXEpTt3cKCOsMFYowKIHKdYT67Ux1oEJ+pmXnW/hW/dmDyFn4hsf9AA6 JPc6jla/+cBNw54101Oo4lk1qvzoQb9RqhQKGTBS3a2It9HmzlH3/3MKJiWpdscKlndS RZ9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796321652; x=1796926452; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=SEaUxn79TCL9Ge2RAskhq69MW9cK805ksQSL3CjI4FA=; b=d5rAjuiYo/0za/6xZtoTrtLmCgnvKoyM2So30LtLP7n4bnzosfpyj+vyWdZyE1lRq7 DWardBTcqeaMuDOrlWlMBhDzuH9baWxq1zuMuf+YsxEeIO6Bsun41IVzG7fYHXqVigse FlhxuTre9oTMuR99WwfDO3qWGUqaolhrj6HMSHL11c2ZUrso9XjZSJ2RNOSlMEhjvFyW BPrpmgScWXyS5v0LNZJrV0w7SCsZF7gznRrKYR8lb2yhYdriddy+3JprL0YH8jdDDP+0 zGxdN/i91b8YXXTpg9K+HNmro1ewImVlHOCcqwU0B4OdRUdup0dvjRJEVabmzM5UGMrr PmVA== X-Gm-Message-State: APuU4Z/8w4LxvRsf/vj+KjNQjwZXtqBvhNx0D2McDcSn47xcZMszA8KW gzQsLfyGwle9zC4R/Jw9TikRU6ELZFVD6Xczcrhe420AQXLGq9ugrzeHxSfKlqXD X-Gm-Gg: AZFdTZdCOQNWUpzlF7ure4T7CSl29jkYMq9YzYvhCzhgljC+C1l8hYyKqZQIw7yhu2H uR2NpNRGv+N3u6vKu2hmQ/CNvnSOpUmzY1I2fCQ4l22dmlo4Be7SdHjKVx4ds96Of4SHWwIWFQi TaDo0pVn1mUYOYA0UsHVDOgjDrLpFHrFu8ZMIzlJv4nHKsvt3FRYSaz70qNBba2A8Ertfnq2iPT ksX+/jlAMVTDSmCXAQSdV/r92jdSZeWM871c0rkafqv3y1ULurhVWjsnSJ4eBGe+7XYgWo0sZB3 /0YJQyetw7kpKwujCigtBsVHhxwGVkzk2f5MFmHTMCgB8Nh6mA0MdXUaVOMppFADPbkWURoA/Gr 5w+O2doBw0f2hNUcn+ac3U9iti8/sFrACtpDRDpPqm1M3eJtOb3WF4NAstppB2wNWNOyZF8SvdR Vpe57WpYqh4sNU9qTxtTVI+7Eoisb0OVpHCFOSGklE0yg2harcT9+gs/645YRZdGbYgh9nRnStI J2Hm24Q7bSCE9VOmEmtXUeDTzH0fZBUZpnBOI+wpA1p6jQL8/ZhrV2eH+g1r/gD2y/3ss5d3ICj pSpT3wDCAAt7/UQum0vmUiIHdjeWI1mDJ54/Sk1tjXG05rx8PU+zHGfewf66CfGJOpiUCZOXepQ TSizqVpMeu+SzGknyJv/PMOXaq7CzhngPrvVBvKiRXn/nwmjntrUu0Gk= X-Received: by 2002:a05:6122:208e:b0:5da:a74:d6a4 with SMTP id 71dfb90a1353d-5ee8af2581fmr31257962e0c.15.1796321652485; Thu, 03 Dec 2026 10:14:12 -0800 (PST) Received: from lvondent-mobl5 ([72.188.211.115]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-5f01a1c2133sm202284e0c.2.2026.12.03.10.14.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2026 10:14:12 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH v17 1/2] Bluetooth: L2CAP: Restrict LE credits to connected CoCs Date: Thu, 3 Dec 2026 13:14:00 -0500 Message-ID: <20261203181401.774560-2-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261203181401.774560-1-luiz.dentz@gmail.com> References: <20261203181401.774560-1-luiz.dentz@gmail.com> X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Kyle Pepper 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. Fixes: fad5fc89594d ("Bluetooth: Add LE flow control discipline") Signed-off-by: Kyle Pepper Assisted-by: OpenCode:claude-opus-5.5 Signed-off-by: Luiz Augusto von Dentz --- net/bluetooth/l2cap_core.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index edbfb775a375..211d6ad23774 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -5572,6 +5572,15 @@ static inline int l2cap_le_credits(struct l2cap_conn *conn, l2cap_chan_lock(chan); + /* Credits are only accounted for established channels, including + * the ones waiting for a security upgrade requested with BT_SECURITY + * so the credits granted by the peer meanwhile are not lost. + */ + if ((chan->state != BT_CONNECTED && chan->state != BT_CONFIG) || + (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"); @@ -5585,6 +5594,12 @@ static inline int l2cap_le_credits(struct l2cap_conn *conn, chan->tx_credits += credits; + /* Don't resume a channel with a pending security upgrade, it is + * resumed by l2cap_security_cfm() once the upgrade completes. + */ + if (chan->state != BT_CONNECTED) + goto unlock; + /* Resume sending */ l2cap_le_flowctl_send(chan); -- 2.56.1