Patch "sctp: fix potential deadlock on &net->sctp.addr_wq_lock" has been added to the 5.4-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

    sctp: fix potential deadlock on &net->sctp.addr_wq_lock

to the 5.4-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:
     sctp-fix-potential-deadlock-on-net-sctp.addr_wq_lock.patch
and it can be found in the queue-5.4 subdirectory.

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



commit a6f7a997392fb2d43f8c55c7b2bda3e3cfc93ba0
Author: Chengfeng Ye <dg573847474@xxxxxxxxx>
Date:   Tue Jun 27 12:03:40 2023 +0000

    sctp: fix potential deadlock on &net->sctp.addr_wq_lock
    
    [ Upstream commit 6feb37b3b06e9049e20dcf7e23998f92c9c5be9a ]
    
    As &net->sctp.addr_wq_lock is also acquired by the timer
    sctp_addr_wq_timeout_handler() in protocal.c, the same lock acquisition
    at sctp_auto_asconf_init() seems should disable irq since it is called
    from sctp_accept() under process context.
    
    Possible deadlock scenario:
    sctp_accept()
        -> sctp_sock_migrate()
        -> sctp_auto_asconf_init()
        -> spin_lock(&net->sctp.addr_wq_lock)
            <timer interrupt>
            -> sctp_addr_wq_timeout_handler()
            -> spin_lock_bh(&net->sctp.addr_wq_lock); (deadlock here)
    
    This flaw was found using an experimental static analysis tool we are
    developing for irq-related deadlock.
    
    The tentative patch fix the potential deadlock by spin_lock_bh().
    
    Signed-off-by: Chengfeng Ye <dg573847474@xxxxxxxxx>
    Fixes: 34e5b0118685 ("sctp: delay auto_asconf init until binding the first addr")
    Acked-by: Xin Long <lucien.xin@xxxxxxxxx>
    Link: https://lore.kernel.org/r/20230627120340.19432-1-dg573847474@xxxxxxxxx
    Signed-off-by: Paolo Abeni <pabeni@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index bf3fed5b91d2b..7cff1a031f761 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -362,9 +362,9 @@ static void sctp_auto_asconf_init(struct sctp_sock *sp)
 	struct net *net = sock_net(&sp->inet.sk);
 
 	if (net->sctp.default_auto_asconf) {
-		spin_lock(&net->sctp.addr_wq_lock);
+		spin_lock_bh(&net->sctp.addr_wq_lock);
 		list_add_tail(&sp->auto_asconf_list, &net->sctp.auto_asconf_splist);
-		spin_unlock(&net->sctp.addr_wq_lock);
+		spin_unlock_bh(&net->sctp.addr_wq_lock);
 		sp->do_auto_asconf = 1;
 	}
 }



[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