netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: clean the sk_frag.page of new cloned socket
@ 2018-01-25 12:08 Li RongQing
  2018-01-25 12:44 ` Eric Dumazet
  0 siblings, 1 reply; 8+ messages in thread
From: Li RongQing @ 2018-01-25 12:08 UTC (permalink / raw)
  To: netdev; +Cc: edumazet

Clean the sk_frag.page of new cloned socket, otherwise it will release
twice wrongly since the reference count of this sk_frag page is not
increased.

sk_clone_lock() is used to clone a new socket from sock which is in
listening state and has not sk_frag.page, but a socket has sent data
and can gets transformed back to a listening socket, will allocate an
tcp_sock through sk_clone_lock() when a new connection comes in.

Signed-off-by: Li RongQing <lirongqing@baidu.com>
Cc: Eric Dumazet <edumazet@google.com>
---
 net/core/sock.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/core/sock.c b/net/core/sock.c
index c0b5b2f17412..c845856f26da 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -1738,6 +1738,8 @@ struct sock *sk_clone_lock(const struct sock *sk, const gfp_t priority)
 		sk_refcnt_debug_inc(newsk);
 		sk_set_socket(newsk, NULL);
 		newsk->sk_wq = NULL;
+		newsk->sk_frag.page = NULL;
+		newsk->sk_frag.offset = 0;
 
 		if (newsk->sk_prot->sockets_allocated)
 			sk_sockets_allocated_inc(newsk);
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-01-26  5:16 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-25 12:08 [PATCH] net: clean the sk_frag.page of new cloned socket Li RongQing
2018-01-25 12:44 ` Eric Dumazet
2018-01-26  2:09   ` 答复: " Li,Rongqing
2018-01-26  3:03     ` Eric Dumazet
2018-01-26  3:21       ` 答复: " Li,Rongqing
2018-01-26  3:14     ` Eric Dumazet
2018-01-26  3:23       ` 答复: " Li,Rongqing
2018-01-26  5:16       ` Cong Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).