]> git.baikalelectronics.ru Git - kernel.git/commit
net/sctp: fix race condition in sctp_destroy_sock
authorOr Cohen <orcohen@paloaltonetworks.com>
Tue, 13 Apr 2021 18:10:31 +0000 (21:10 +0300)
committerDavid S. Miller <davem@davemloft.net>
Tue, 13 Apr 2021 21:59:46 +0000 (14:59 -0700)
commit602a5a10de8dff411eaf1c560e7459159df8c4ef
treeddc605b5d010d800b84225d1113abb26641e95a4
parent3d24a35e2166d0b618d132dbfe675b4806b07773
net/sctp: fix race condition in sctp_destroy_sock

If sctp_destroy_sock is called without sock_net(sk)->sctp.addr_wq_lock
held and sp->do_auto_asconf is true, then an element is removed
from the auto_asconf_splist without any proper locking.

This can happen in the following functions:
1. In sctp_accept, if sctp_sock_migrate fails.
2. In inet_create or inet6_create, if there is a bpf program
   attached to BPF_CGROUP_INET_SOCK_CREATE which denies
   creation of the sctp socket.

The bug is fixed by acquiring addr_wq_lock in sctp_destroy_sock
instead of sctp_close.

This addresses CVE-2021-23133.

Reported-by: Or Cohen <orcohen@paloaltonetworks.com>
Reviewed-by: Xin Long <lucien.xin@gmail.com>
Fixes: cf0204725308 ("bpf: Add new cgroup attach type to enable sock modifications")
Signed-off-by: Or Cohen <orcohen@paloaltonetworks.com>
Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sctp/socket.c