Skip to contentSkip to conversation

Bluetooth: L2CAP: Fix possible crash on l2cap_ecred_conn_rsp

PATCH Superseded Luiz Augusto von Dentz 2 participants 2 messages May 11

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH 1/1 Bluetooth: L2CAP: Fix possible crash on l2cap_ecred_conn_rsp

From: Luiz Augusto von Dentz <[email protected]>

If dcid is received for an already-assigned destination CID the spec requires that both channels to be discarded, but calling l2cap_chan_del may invalidate the tmp cursor created by list_for_each_entry_safe and in fact it is the wrong procedure as the chan->dcid may be assigned previously it really needs to be disconnected using l2cap_send_disconn_req otherwise the remote peer would have no idea that it shall consider to be disconnected.

---
 net/bluetooth/l2cap_core.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
net/bluetooth/l2cap_core.c +5 -1
index fdccd62ccca8..71846849e5b0 100644
@@ -5293,7 +5293,11 @@ static inline int l2cap_ecred_conn_rsp(struct l2cap_conn *conn,
 			l2cap_chan_unlock(chan);
 			chan = __l2cap_get_chan_by_dcid(conn, dcid);
 			l2cap_chan_lock(chan);
-			l2cap_chan_del(chan, ECONNRESET);
+			/* Disconnect the original channel as it may be
+			 * considered connected since dcid has already been
+			 * assigned.
+			 */
+			l2cap_send_disconn_req(chan, ECONNRESET);
 			l2cap_chan_unlock(chan);
 			continue;
 		}
Signature · 1 line
2.53.0
#1 lore raw

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=1092945

---Test result---

Test Summary:

CheckPatch                    PASS      0.75 seconds
GitLint                       PASS      0.35 seconds
SubjectPrefix                 PASS      0.13 seconds
BuildKernel                   PASS      27.00 seconds
CheckAllWarning               PASS      29.77 seconds
CheckSparse                   PASS      28.32 seconds
BuildKernel32                 PASS      26.13 seconds
TestRunnerSetup               PASS      579.48 seconds
TestRunner_l2cap-tester       PASS      372.74 seconds
IncrementalBuild              PASS      26.99 seconds

https://github.com/bluez/bluetooth-next/pull/171

---
Regards,
Linux Bluetooth