linux/include/net/bluetooth
Gustavo F. Padovan e454c84464 Bluetooth: Fix deadlock in the ERTM logic
The Enhanced Retransmission Mode(ERTM) is a realiable mode of operation
of the Bluetooth L2CAP layer. Think on it like a simplified version of
TCP.
The problem we were facing here was a deadlock. ERTM uses a backlog
queue to queue incomimg packets while the user is helding the lock. At
some moment the sk_sndbuf can be exceeded and we can't alloc new skbs
then the code sleep with the lock to wait for memory, that stalls the
ERTM connection once we can't read the acknowledgements packets in the
backlog queue to free memory and make the allocation of outcoming skb
successful.

This patch actually affect all users of bt_skb_send_alloc(), i.e., all
L2CAP modes and SCO.

We are safe against socket states changes or channels deletion while the
we are sleeping wait memory. Checking for the sk->sk_err and
sk->sk_shutdown make the code safe, since any action that can leave the
socket or the channel in a not usable state set one of the struct
members at least. Then we can check both of them when getting the lock
again and return with the proper error if something unexpected happens.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Signed-off-by: Ulisses Furquim <ulisses@profusion.mobi>
2010-09-30 12:19:35 -03:00
..
bluetooth.h Bluetooth: Fix deadlock in the ERTM logic 2010-09-30 12:19:35 -03:00
hci.h Bluetooth: Use __packed annotation 2010-07-21 10:39:13 -07:00
hci_core.h Bluetooth: Use list_head for HCI blacklist head 2010-07-31 16:06:58 -07:00
l2cap.h Bluetooth: Use 3-DH5 payload size for default ERTM max PDU size 2010-08-10 07:59:11 -04:00
rfcomm.h Bluetooth: Use __packed annotation 2010-07-21 10:39:13 -07:00
sco.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00