linux-kernel-mentees.lists.linuxfoundation.org archive mirror
 help / color / mirror / Atom feed
* [Linux-kernel-mentees] [PATCH] Bluetooth: Initialize the TX queue lock when creating struct l2cap_chan in 6LOWPAN
@ 2020-08-04  9:39 Coiby Xu
  2020-08-04  9:42 ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: Coiby Xu @ 2020-08-04  9:39 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: Johan Hedberg, open list:NETWORKING [GENERAL],
	Marcel Holtmann, open list, Jakub Kicinski,
	syzbot+fadfba6a911f6bf71842, linux-kernel-mentees,
	David S. Miller

When L2CAP channel is destroyed by hci_unregister_dev, it will
acquire the spin lock of the (struct l2cap_chan *)->tx_q list to
delete all the buffers. But sometimes when hci_unregister_dev is
being called, this lock may have not bee initialized. Initialize
the TX queue lock when creating struct l2cap_chan in 6LOWPAN to fix
this problem.

Reported-by: syzbot+fadfba6a911f6bf71842@syzkaller.appspotmail.com
Link: https://syzkaller.appspot.com/bug?extid=fadfba6a911f6bf71842
Signed-off-by: Coiby Xu <coiby.xu@gmail.com>
---
 net/bluetooth/6lowpan.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c
index bb55d92691b0..713c618a73df 100644
--- a/net/bluetooth/6lowpan.c
+++ b/net/bluetooth/6lowpan.c
@@ -651,6 +651,7 @@ static struct l2cap_chan *chan_create(void)
 
 	l2cap_chan_set_defaults(chan);
 
+	skb_queue_head_init(&chan->tx_q);
 	chan->chan_type = L2CAP_CHAN_CONN_ORIENTED;
 	chan->mode = L2CAP_MODE_LE_FLOWCTL;
 	chan->imtu = 1280;
-- 
2.27.0

_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Linux-kernel-mentees] [PATCH] Bluetooth: Initialize the TX queue lock when creating struct l2cap_chan in 6LOWPAN
  2020-08-04  9:39 [Linux-kernel-mentees] [PATCH] Bluetooth: Initialize the TX queue lock when creating struct l2cap_chan in 6LOWPAN Coiby Xu
@ 2020-08-04  9:42 ` Greg KH
  2020-08-04 10:41   ` Coiby Xu
  0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2020-08-04  9:42 UTC (permalink / raw)
  To: Coiby Xu
  Cc: Johan Hedberg, open list:NETWORKING [GENERAL],
	Marcel Holtmann, open list, linux-bluetooth, Jakub Kicinski,
	syzbot+fadfba6a911f6bf71842, linux-kernel-mentees,
	David S. Miller

On Tue, Aug 04, 2020 at 05:39:37PM +0800, Coiby Xu wrote:
> When L2CAP channel is destroyed by hci_unregister_dev, it will
> acquire the spin lock of the (struct l2cap_chan *)->tx_q list to
> delete all the buffers. But sometimes when hci_unregister_dev is
> being called, this lock may have not bee initialized. Initialize
> the TX queue lock when creating struct l2cap_chan in 6LOWPAN to fix
> this problem.
> 
> Reported-by: syzbot+fadfba6a911f6bf71842@syzkaller.appspotmail.com
> Link: https://syzkaller.appspot.com/bug?extid=fadfba6a911f6bf71842
> Signed-off-by: Coiby Xu <coiby.xu@gmail.com>
> ---
>  net/bluetooth/6lowpan.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c
> index bb55d92691b0..713c618a73df 100644
> --- a/net/bluetooth/6lowpan.c
> +++ b/net/bluetooth/6lowpan.c
> @@ -651,6 +651,7 @@ static struct l2cap_chan *chan_create(void)
>  
>  	l2cap_chan_set_defaults(chan);
>  
> +	skb_queue_head_init(&chan->tx_q);
>  	chan->chan_type = L2CAP_CHAN_CONN_ORIENTED;
>  	chan->mode = L2CAP_MODE_LE_FLOWCTL;
>  	chan->imtu = 1280;

Nice, did syzbot verify that this resolves the issue?

thanks,

greg k-h
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Linux-kernel-mentees] [PATCH] Bluetooth: Initialize the TX queue lock when creating struct l2cap_chan in 6LOWPAN
  2020-08-04  9:42 ` Greg KH
@ 2020-08-04 10:41   ` Coiby Xu
  0 siblings, 0 replies; 3+ messages in thread
From: Coiby Xu @ 2020-08-04 10:41 UTC (permalink / raw)
  To: Greg KH
  Cc: Johan Hedberg, open list:NETWORKING [GENERAL],
	Marcel Holtmann, open list, linux-bluetooth, Jakub Kicinski,
	syzbot+fadfba6a911f6bf71842, linux-kernel-mentees,
	David S. Miller

On Tue, Aug 04, 2020 at 11:42:53AM +0200, Greg KH wrote:
>On Tue, Aug 04, 2020 at 05:39:37PM +0800, Coiby Xu wrote:
>> When L2CAP channel is destroyed by hci_unregister_dev, it will
>> acquire the spin lock of the (struct l2cap_chan *)->tx_q list to
>> delete all the buffers. But sometimes when hci_unregister_dev is
>> being called, this lock may have not bee initialized. Initialize
>> the TX queue lock when creating struct l2cap_chan in 6LOWPAN to fix
>> this problem.
>>
>> Reported-by: syzbot+fadfba6a911f6bf71842@syzkaller.appspotmail.com
>> Link: https://syzkaller.appspot.com/bug?extid=fadfba6a911f6bf71842
>> Signed-off-by: Coiby Xu <coiby.xu@gmail.com>
>> ---
>>  net/bluetooth/6lowpan.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c
>> index bb55d92691b0..713c618a73df 100644
>> --- a/net/bluetooth/6lowpan.c
>> +++ b/net/bluetooth/6lowpan.c
>> @@ -651,6 +651,7 @@ static struct l2cap_chan *chan_create(void)
>>
>>  	l2cap_chan_set_defaults(chan);
>>
>> +	skb_queue_head_init(&chan->tx_q);
>>  	chan->chan_type = L2CAP_CHAN_CONN_ORIENTED;
>>  	chan->mode = L2CAP_MODE_LE_FLOWCTL;
>>  	chan->imtu = 1280;
>
>Nice, did syzbot verify that this resolves the issue?
>
>thanks,
>
>greg k-h

Yes. Thank you for reminding me. I'll also add an Tested-by: tag next time.

--
Best regards,
Coiby
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-08-04 10:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-04  9:39 [Linux-kernel-mentees] [PATCH] Bluetooth: Initialize the TX queue lock when creating struct l2cap_chan in 6LOWPAN Coiby Xu
2020-08-04  9:42 ` Greg KH
2020-08-04 10:41   ` Coiby Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).