Commit 3aaa3648 authored by Or Cohen's avatar Or Cohen Committed by Zheng Zengkai
Browse files

net/sctp: fix race condition in sctp_destroy_sock



stable inclusion
from stable-5.10.32
commit 5a627026be4a17e5b9db23558cd28e62b2cbc66e
bugzilla: 51796

--------------------------------

commit b166a20b upstream.

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: default avatarOr Cohen <orcohen@paloaltonetworks.com>
Reviewed-by: default avatarXin Long <lucien.xin@gmail.com>
Fixes: 61023658 ("bpf: Add new cgroup attach type to enable sock modifications")
Signed-off-by: default avatarOr Cohen <orcohen@paloaltonetworks.com>
Acked-by: default avatarMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarChen Jun <chenjun102@huawei.com>
Acked-by: default avatarWeilong Chen <chenweilong@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent 5bfb6b3a
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment