Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Bluetooth: l2cap: Add missing chan lock in l2cap_ecred_reconf_rsp

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: 15f02b910562 ("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>

authored by

Dudu Lu and committed by
Luiz Augusto von Dentz
42776497 1c0bc11c

+6
+6
net/bluetooth/l2cap_core.c
··· 5473 5473 if (chan->ident != cmd->ident) 5474 5474 continue; 5475 5475 5476 + l2cap_chan_hold(chan); 5477 + l2cap_chan_lock(chan); 5478 + 5476 5479 l2cap_chan_del(chan, ECONNRESET); 5480 + 5481 + l2cap_chan_unlock(chan); 5482 + l2cap_chan_put(chan); 5477 5483 } 5478 5484 5479 5485 return 0;