Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

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@gmail.com>
Fixes: 34e5b0118685 ("sctp: delay auto_asconf init until binding the first addr")
Acked-by: Xin Long <lucien.xin@gmail.com>
Link: https://lore.kernel.org/r/20230627120340.19432-1-dg573847474@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Chengfeng Ye and committed by
Paolo Abeni
6feb37b3 7a8227b2

+2 -2
+2 -2
net/sctp/socket.c
··· 364 364 struct net *net = sock_net(&sp->inet.sk); 365 365 366 366 if (net->sctp.default_auto_asconf) { 367 - spin_lock(&net->sctp.addr_wq_lock); 367 + spin_lock_bh(&net->sctp.addr_wq_lock); 368 368 list_add_tail(&sp->auto_asconf_list, &net->sctp.auto_asconf_splist); 369 - spin_unlock(&net->sctp.addr_wq_lock); 369 + spin_unlock_bh(&net->sctp.addr_wq_lock); 370 370 sp->do_auto_asconf = 1; 371 371 } 372 372 }