android_kernel_xiaomi_sm7250/net/sctp
Xin Long b8fa99a3a1 sctp: handle the error returned from sctp_auth_asoc_init_active_key
[ Upstream commit 022152aaebe116a25c39818a07e175a8cd3c1e11 ]

When it returns an error from sctp_auth_asoc_init_active_key(), the
active_key is actually not updated. The old sh_key will be freeed
while it's still used as active key in asoc. Then an use-after-free
will be triggered when sending patckets, as found by syzbot:

  sctp_auth_shkey_hold+0x22/0xa0 net/sctp/auth.c:112
  sctp_set_owner_w net/sctp/socket.c:132 [inline]
  sctp_sendmsg_to_asoc+0xbd5/0x1a20 net/sctp/socket.c:1863
  sctp_sendmsg+0x1053/0x1d50 net/sctp/socket.c:2025
  inet_sendmsg+0x99/0xe0 net/ipv4/af_inet.c:819
  sock_sendmsg_nosec net/socket.c:714 [inline]
  sock_sendmsg+0xcf/0x120 net/socket.c:734

This patch is to fix it by not replacing the sh_key when it returns
errors from sctp_auth_asoc_init_active_key() in sctp_auth_set_key().
For sctp_auth_set_active_key(), old active_key_id will be set back
to asoc->active_key_id when the same thing happens.

Fixes: 58acd1009226 ("sctp: update active_key for asoc when old key is being replaced")
Reported-by: syzbot+a236dd8e9622ed8954a3@syzkaller.appspotmail.com
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-10-26 13:19:26 +02:00
..
associola.c
auth.c sctp: handle the error returned from sctp_auth_asoc_init_active_key 2022-10-26 13:19:26 +02:00
bind_addr.c sctp: validate from_addr_param return 2021-07-20 16:16:03 +02:00
chunk.c
debug.c
diag.c sctp: fix kernel-infoleak for SCTP sockets 2022-03-16 13:20:26 +01:00
endpointola.c sctp: use call_rcu to free endpoint 2022-01-05 12:34:58 +01:00
input.c sctp: read sk->sk_bound_dev_if once in sctp_rcv() 2022-06-14 16:59:23 +02:00
inqueue.c
ipv6.c sctp: validate from_addr_param return 2021-07-20 16:16:03 +02:00
Kconfig
Makefile
objcnt.c
offload.c
output.c
outqueue.c
primitive.c
proc.c net: fix iteration for sctp transport seq_files 2021-02-23 15:00:58 +01:00
protocol.c ip: Fix data-races around sysctl_ip_nonlocal_bind. 2022-07-29 17:10:31 +02:00
sm_make_chunk.c sctp: account stream padding length for reconf chunk 2021-10-20 11:23:03 +02:00
sm_sideeffect.c sctp: check asoc strreset_chunk in sctp_generate_reconf_event 2022-05-12 12:20:21 +02:00
sm_statefuns.c sctp: fix the processing for INIT_ACK chunk 2022-03-23 09:10:40 +01:00
sm_statetable.c
socket.c sctp: Initialize daddr on peeled off socket 2022-04-20 09:12:48 +02:00
stream_interleave.c
stream_sched_prio.c
stream_sched_rr.c
stream_sched.c sctp: fix sleep in atomic context bug in timer handlers 2022-08-11 12:48:40 +02:00
stream.c
sysctl.c
transport.c sctp: change to hold/put transport for proto_unreach_timer 2020-11-24 13:27:18 +01:00
tsnmap.c
ulpevent.c
ulpqueue.c