summaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
authorLi RongQing <lirongqing@baidu.com>2018-01-26 16:40:41 +0800
committerDavid S. Miller <davem@davemloft.net>2018-01-29 17:56:23 -0500
commit9b42d55a66d388e4dd5550107df051a9637564fc (patch)
tree685bd712d0a69e853828cb0c0331577c3c7e5df0 /net/ipv4
parent30e948a37839c633d18f6c4cf8a212912ba9449c (diff)
downloadlinux-9b42d55a66d388e4dd5550107df051a9637564fc.tar.gz
linux-9b42d55a66d388e4dd5550107df051a9637564fc.tar.bz2
linux-9b42d55a66d388e4dd5550107df051a9637564fc.zip
tcp: release sk_frag.page in tcp_disconnect
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>
Diffstat (limited to 'net/ipv4')
-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 c8ed3a04b504..874c9317b8df 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -2458,6 +2458,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;
}