]> git.baikalelectronics.ru Git - kernel.git/commit
sctp: hold transport before accessing its asoc in sctp_transport_get_next
authorXin Long <lucien.xin@gmail.com>
Mon, 27 Aug 2018 10:38:31 +0000 (18:38 +0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 27 Aug 2018 22:13:17 +0000 (15:13 -0700)
commitdf5dbda39cfd5874deaa436562b2df69b7f391e4
tree6aa14f7a10ba70d73495a48e68875ec30fe013cb
parent1aad0a036ce09a7d2c63a2ca89739fdd463ce2c0
sctp: hold transport before accessing its asoc in sctp_transport_get_next

As Marcelo noticed, in sctp_transport_get_next, it is iterating over
transports but then also accessing the association directly, without
checking any refcnts before that, which can cause an use-after-free
Read.

So fix it by holding transport before accessing the association. With
that, sctp_transport_hold calls can be removed in the later places.

Fixes: e0f10e3bd3ff ("sctp: export some apis or variables for sctp_diag and reuse some for proc")
Reported-by: syzbot+fe62a0c9aa6a85c6de16@syzkaller.appspotmail.com
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sctp/proc.c
net/sctp/socket.c