sctp: add the missing sock_owned_by_user check in sctp_icmp_redirect
authorXin Long <>
Wed, 18 Oct 2017 13:37:49 +0000 (21:37 +0800)
committerDavid S. Miller <>
Fri, 20 Oct 2017 11:53:45 +0000 (12:53 +0100)
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 45caeaa5ac0b ("dccp/tcp: fix
routing redirect race") on sctp also needs this check.

Fixes: 55be7a9c6074 ("ipv4: Add redirect support to all protocol icmp error handlers")
Reported-by: Eric Dumazet <>
Signed-off-by: Xin Long <>
Acked-by: Marcelo Ricardo Leitner <>
Acked-by: Neil Horman <>
Signed-off-by: David S. Miller <>

index 92a07141fd07396a816478569f6de18a2aa13ebb..34f10e75f3b951a6fce87092a9af58dddb1f891b 100644 (file)
@@ -421,7 +421,7 @@ void sctp_icmp_redirect(struct sock *sk, struct sctp_transport *t,
        struct dst_entry *dst;
-       if (!t)
+       if (sock_owned_by_user(sk) || !t)
        dst = sctp_transport_dst_check(t);
        if (dst)