Skip to content

Commit fe1188a

Browse files
phx0fergregkh
authored andcommitted
Bluetooth: l2cap: Add missing chan lock in l2cap_ecred_reconf_rsp
[ Upstream commit 4277649 ] l2cap_ecred_reconf_rsp() calls l2cap_chan_del() without holding l2cap_chan_lock(). Every other l2cap_chan_del() caller in the file acquires the lock first. A remote BLE device can send a crafted L2CAP ECRED reconfiguration response to corrupt the channel list while another thread is iterating it. Add l2cap_chan_hold() and l2cap_chan_lock() before l2cap_chan_del(), and l2cap_chan_unlock() and l2cap_chan_put() after, matching the pattern used in l2cap_ecred_conn_rsp() and l2cap_conn_del(). Fixes: 15f02b9 ("Bluetooth: L2CAP: Add initial code for Enhanced Credit Based Mode") Signed-off-by: Dudu Lu <phx0fer@gmail.com> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 541d5bf commit fe1188a

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

net/bluetooth/l2cap_core.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5399,7 +5399,13 @@ static inline int l2cap_ecred_reconf_rsp(struct l2cap_conn *conn,
53995399
if (chan->ident != cmd->ident)
54005400
continue;
54015401

5402+
l2cap_chan_hold(chan);
5403+
l2cap_chan_lock(chan);
5404+
54025405
l2cap_chan_del(chan, ECONNRESET);
5406+
5407+
l2cap_chan_unlock(chan);
5408+
l2cap_chan_put(chan);
54035409
}
54045410

54055411
return 0;

0 commit comments

Comments
 (0)