summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLi RongQing <lirongqing@baidu.com>2018-01-26 16:40:41 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-02-13 10:19:47 +0100
commit6d35430fdaf47880cacda975a7d1b1588f933357 (patch)
tree59c76a17c5f615847d2ecddaad07522a3dd3420d
parente8513f250d1b632f17cf909ff6b76293adc5f682 (diff)
tcp: release sk_frag.page in tcp_disconnect
[ Upstream commit 9b42d55a66d388e4dd5550107df051a9637564fc ] socket can be disconnected and gets transformed back to a listening socket, if sk_frag.page is not released, which will be cloned into a new socket by sk_clone_lock, but the reference count of this page is increased, lead to a use after free or double free issue Signed-off-by: Li RongQing <lirongqing@baidu.com> Cc: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--net/ipv4/tcp.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 2a65d806b562..fe11128d7df4 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -2379,6 +2379,12 @@ int tcp_disconnect(struct sock *sk, int flags)
WARN_ON(inet->inet_num && !icsk->icsk_bind_hash);
+ if (sk->sk_frag.page) {
+ put_page(sk->sk_frag.page);
+ sk->sk_frag.page = NULL;
+ sk->sk_frag.offset = 0;
+ }
+
sk->sk_error_report(sk);
return err;
}