From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794585232; b=hs+L+vDZGqFr4cVOJYI6IuFhmmNppD1x/H+oAgCpwg069TgPRsxesn7JYm2awtZ4iSas p6vWzX1DpbVDmMkd8mZ///T7rxnbbl9HmiEbAf3Cb/RcC818XCqEz7dImMAk+i6+Vdmrs ckBd9e8pJmYHbpmdiScoGLEAlT/+G2LkXUjZtjl6OvugcbfhDFUjCNYYd9/gKAvRE2ojv A/AD5r8c118D+GFV+W1BPYWHP2f+kc8mZOba8EfDqofVZOSECkkc39keK3KES5x+jl8Vx PiAU58JAlVazb7oXWqVuGq8O8Zcmbj3sZDANYYqMVGyA92HPAuuwLWKkYBOcuz4ZqyQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794585232; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=C40+8pjaf0eSe3VK5vDO/6q5geGLdfvtsy/4VFlf2p4=; b=F/hjVUwV3rtBnZfSWx/PVq5lur32IX0GsMwRgTqopFtEXwIE/iQUEDFdxHTHEPWTZdTA eDVcvdgUmgnqeNpGlRGli2MMnxRvhgDZ54of1cjWjVM4dx1hmQ+bOCX6N1QkyBgIsxI3U LYLs1B80edUQgM16lK0zXLQY02rgT43k4nNWH1VEpSIDx2YL+iCygprrVqSZxIVAQP1xB +59U1QURkXHo+G+nUoIoK8RD0RF94fJmII4DVVcLT3+vReBoeXQuKC9UL2c6Z12aFsZES rs5H/WMgaX5+fXIB1w4fCCH9EJxBYzPLBV7qu7HvDey6oCv2jVDSWzmZ7rPhOLkUVyw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=jTe+GF+d; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B8F4C606A33A; Fri, 13 Nov 2026 15:53:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=jTe+GF+d Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3B27A1F000C4; Fri, 13 Nov 2026 15:53:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1794585232; bh=C40+8pjaf0eSe3VK5vDO/6q5geGLdfvtsy/4VFlf2p4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=jTe+GF+dOsus+cpLnBPfuPOjZipKt6yltCYEgPrx0r1dcU5cJTzKYkFMFkkwe6Bnh UlFji90AcmbXyLXoO5YnrTCqvkxCOxqH5sBAHEzkZFiS69iuzCxMdZavsKRz6Jchs1 db3Q/zXZcmqkwxRQpHhuTu4ZWaCIctWAyIoViXEI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Siwei Zhang , Luiz Augusto von Dentz , Sasha Levin Subject: [PATCH 7.3 002/507] Bluetooth: L2CAP: Reject signalling responses in invalid states Date: Fri, 13 Nov 2026 10:45:06 -0500 Message-ID: <20261113153753.457783287@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261113153753.358973689@linuxfoundation.org> References: <20261113153753.358973689@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@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 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Siwei Zhang commit 6320736af7dcb90da6ee9fd651ecc11c564d45b7 upstream. Adjusted context as stable does not have the lockdep_assert_held() calls, and l2cap_get_chan_by_scid() still returns the channel locked, so l2cap_config_rsp() does not lock it again. A peer can send configuration messages while an incoming channel is in BT_CONNECT2, before the security or deferred accept gate has completed. A configuration response can then promote the channel to BT_CONNECTED. Configuration responses can also act on channels that are closing, and a late connection response can move a disconnecting channel back to BT_CONFIG. Accept connection responses only while waiting in BT_CONNECT. Answer configuration requests in BT_CONNECT2, but defer our own request until BT_CONFIG so configuration cannot complete before the gate. Ignore configuration responses outside BT_CONFIG and BT_CONNECTED, and only complete configuration in BT_CONFIG. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Cc: stable@vger.kernel.org Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Siwei Zhang Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Sasha Levin --- net/bluetooth/l2cap_core.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index b86999899f669..3e57c605cf8be 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -4311,6 +4311,10 @@ static int l2cap_connect_create_rsp(struct l2cap_conn *conn, l2cap_chan_lock(chan); + /* Ignore a late response after the channel has left BT_CONNECT. */ + if (chan->state != BT_CONNECT) + goto done; + switch (result) { case L2CAP_CR_SUCCESS: if (__l2cap_get_chan_by_dcid(conn, dcid)) { @@ -4340,6 +4344,7 @@ static int l2cap_connect_create_rsp(struct l2cap_conn *conn, break; } +done: l2cap_chan_unlock(chan); l2cap_chan_put(chan); @@ -4472,7 +4477,13 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, goto unlock; } - if (!test_and_set_bit(CONF_REQ_SENT, &chan->conf_state)) { + /* A channel in BT_CONNECT2 has not passed security or userspace + * accept yet. Answer the peer's request, but hold our own until + * the channel reaches BT_CONFIG: the CONNECT2 -> CONFIG sites send + * it. Connected channels may also need to reconfigure. + */ + if ((chan->state == BT_CONFIG || chan->state == BT_CONNECTED) && + !test_and_set_bit(CONF_REQ_SENT, &chan->conf_state)) { u8 buf[64]; l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ, l2cap_build_conf_req(chan, buf, sizeof(buf)), buf); @@ -4520,6 +4531,10 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, if (!chan) return 0; + /* Connected channels may also receive reconfiguration responses. */ + if (chan->state != BT_CONFIG && chan->state != BT_CONNECTED) + goto done; + switch (result) { case L2CAP_CONF_SUCCESS: l2cap_conf_rfc_get(chan, rsp->data, len); @@ -4587,6 +4602,9 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, if (test_bit(CONF_OUTPUT_DONE, &chan->conf_state)) { set_default_fcs(chan); + if (chan->state != BT_CONFIG) + goto done; + if (chan->mode == L2CAP_MODE_ERTM || chan->mode == L2CAP_MODE_STREAMING) err = l2cap_ertm_init(chan); -- 2.53.0