Patch "Bluetooth: L2CAP: initialize delayed works at l2cap_chan_create()" has been added to the 6.0-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    Bluetooth: L2CAP: initialize delayed works at l2cap_chan_create()

to the 6.0-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     bluetooth-l2cap-initialize-delayed-works-at-l2cap_ch.patch
and it can be found in the queue-6.0 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit cce48609c8ef8523fb790f57db7e1189f2ff8ea2
Author: Tetsuo Handa <penguin-kernel@xxxxxxxxxxxxxxxxxxx>
Date:   Sun Sep 4 00:32:56 2022 +0900

    Bluetooth: L2CAP: initialize delayed works at l2cap_chan_create()
    
    [ Upstream commit 2d2cb3066f2c90cd8ca540b36ba7a55e7f2406e0 ]
    
    syzbot is reporting cancel_delayed_work() without INIT_DELAYED_WORK() at
    l2cap_chan_del() [1], for CONF_NOT_COMPLETE flag (which meant to prevent
    l2cap_chan_del() from calling cancel_delayed_work()) is cleared by timer
    which fires before l2cap_chan_del() is called by closing file descriptor
    created by socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_L2CAP).
    
    l2cap_bredr_sig_cmd(L2CAP_CONF_REQ) and l2cap_bredr_sig_cmd(L2CAP_CONF_RSP)
    are calling l2cap_ertm_init(chan), and they call l2cap_chan_ready() (which
    clears CONF_NOT_COMPLETE flag) only when l2cap_ertm_init(chan) succeeded.
    
    l2cap_sock_init() does not call l2cap_ertm_init(chan), and it instead sets
    CONF_NOT_COMPLETE flag by calling l2cap_chan_set_defaults(). However, when
    connect() is requested, "command 0x0409 tx timeout" happens after 2 seconds
     from connect() request, and CONF_NOT_COMPLETE flag is cleared after 4
    seconds from connect() request, for l2cap_conn_start() from
    l2cap_info_timeout() callback scheduled by
    
      schedule_delayed_work(&conn->info_timer, L2CAP_INFO_TIMEOUT);
    
    in l2cap_connect() is calling l2cap_chan_ready().
    
    Fix this problem by initializing delayed works used by L2CAP_MODE_ERTM
    mode as soon as l2cap_chan_create() allocates a channel, like I did in
    commit be8597239379f0f5 ("Bluetooth: initialize skb_queue_head at
    l2cap_chan_create()").
    
    Link: https://syzkaller.appspot.com/bug?extid=83672956c7aa6af698b3 [1]
    Reported-by: syzbot <syzbot+83672956c7aa6af698b3@xxxxxxxxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Tetsuo Handa <penguin-kernel@xxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@xxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 2c9de67daadc..770891f68703 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -61,6 +61,9 @@ static void l2cap_send_disconn_req(struct l2cap_chan *chan, int err);
 
 static void l2cap_tx(struct l2cap_chan *chan, struct l2cap_ctrl *control,
 		     struct sk_buff_head *skbs, u8 event);
+static void l2cap_retrans_timeout(struct work_struct *work);
+static void l2cap_monitor_timeout(struct work_struct *work);
+static void l2cap_ack_timeout(struct work_struct *work);
 
 static inline u8 bdaddr_type(u8 link_type, u8 bdaddr_type)
 {
@@ -476,6 +479,9 @@ struct l2cap_chan *l2cap_chan_create(void)
 	write_unlock(&chan_list_lock);
 
 	INIT_DELAYED_WORK(&chan->chan_timer, l2cap_chan_timeout);
+	INIT_DELAYED_WORK(&chan->retrans_timer, l2cap_retrans_timeout);
+	INIT_DELAYED_WORK(&chan->monitor_timer, l2cap_monitor_timeout);
+	INIT_DELAYED_WORK(&chan->ack_timer, l2cap_ack_timeout);
 
 	chan->state = BT_OPEN;
 
@@ -3320,10 +3326,6 @@ int l2cap_ertm_init(struct l2cap_chan *chan)
 	chan->rx_state = L2CAP_RX_STATE_RECV;
 	chan->tx_state = L2CAP_TX_STATE_XMIT;
 
-	INIT_DELAYED_WORK(&chan->retrans_timer, l2cap_retrans_timeout);
-	INIT_DELAYED_WORK(&chan->monitor_timer, l2cap_monitor_timeout);
-	INIT_DELAYED_WORK(&chan->ack_timer, l2cap_ack_timeout);
-
 	skb_queue_head_init(&chan->srej_q);
 
 	err = l2cap_seq_list_init(&chan->srej_list, chan->tx_win);



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux