]> git.baikalelectronics.ru Git - kernel.git/commit
sctp: add the missing sock_owned_by_user check in sctp_icmp_redirect
authorXin Long <lucien.xin@gmail.com>
Wed, 18 Oct 2017 13:37:49 +0000 (21:37 +0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 20 Oct 2017 11:53:45 +0000 (12:53 +0100)
commit74d562e053747d505bf6c53336939af3ed14727d
tree71b86cf028499fe8d327f3a1b660fd3bb79264e0
parent473012681bc565fba5485d85df243aee44d68d48
sctp: add the missing sock_owned_by_user check in sctp_icmp_redirect

Now sctp processes icmp redirect packet in sctp_icmp_redirect where
it calls sctp_transport_dst_check in which tp->dst can be released.

The problem is before calling sctp_transport_dst_check, it doesn't
check sock_owned_by_user, which means tp->dst could be freed while
a process is accessing it with owning the socket.

An use-after-free issue could be triggered by this.

This patch is to fix it by checking sock_owned_by_user before calling
sctp_transport_dst_check in sctp_icmp_redirect, so that it would not
release tp->dst if users still hold sock lock.

Besides, the same issue fixed in commit 63a6c8debe95 ("dccp/tcp: fix
routing redirect race") on sctp also needs this check.

Fixes: e4e9236d4543 ("ipv4: Add redirect support to all protocol icmp error handlers")
Reported-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sctp/input.c