Hi Minho,
* Minho Ban [off-list ref] [2012-05-21 09:58:19 +0900]:
If l2cap_chan_send is called will null conn it will cause kernel Oops.
This patch checks if conn is valid before entering l2cap_chan_send.
chan->conn should be always valid, and if not we have a bug somewhere else in
the code and not in l2cap_chan_send(). It could be a locking problem maybe.
Also check if you can reproduce this with latest bluetooth-next.
Gustavo
From: Minho Ban <hidden> Date: 2012-05-22 01:21:06
On 05/22/2012 01:17 AM, Gustavo Padovan wrote:
Hi Minho,
* Minho Ban [off-list ref] [2012-05-21 09:58:19 +0900]:
quoted
If l2cap_chan_send is called will null conn it will cause kernel Oops.
This patch checks if conn is valid before entering l2cap_chan_send.
chan->conn should be always valid, and if not we have a bug somewhere else in
the code and not in l2cap_chan_send(). It could be a locking problem maybe.
Also check if you can reproduce this with latest bluetooth-next.
Gustavo
Thanks for comment. I'm using bluetooth-next backporting to kernel 3.0
I wonder how do we guarantee chan->conn is valid if other thread release chan->lock
just after exit l2cap_chan_del.
It seem l2cap_chan_del is well protected with various mutex (eg, sk, conn, chan) but
that may not enough to prevent lock waiters from accessing object.
Regards,
Minho Ban
Beside !chan->conn condition,I think it makes sense that sk_state check should be moved after l2cap_chan_lock()
because sk_state could be changed due to l2cap_conn_del().
I think sk->state could be protected by l2cap_chan_lock() in the below procedure.
l2cap_conn_del()
->l2cap_chan_lock()
->l2cap_chan_del()
-> lock_sock()
__l2cap_sock_state_change() *
-> release_sock()
->l2cap_chan_unlock()
BR
Chanyeol Park.
Beside !chan->conn condition,I think it makes sense that sk_state check should be moved after l2cap_chan_lock()
because sk_state could be changed due to l2cap_conn_del().
Thanks, chan->conn condition is not necessary, move sk->sk_state != BT_CONNECTED behind chan_lock is enough.
I'll amend this patch.
Regards
Minho Ban