mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 20:22:09 +00:00
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>
This commit is contained in:
parent
30e948a378
commit
9b42d55a66
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user