All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] net: diag: Don't double-free TCP_NEW_SYN_RECV sockets in tcp_abort
@ 2018-07-07  7:31 Lorenzo Colitti
  2018-07-07 13:11 ` David Miller
                   ` (3 more replies)
  0 siblings, 4 replies; 20+ messages in thread
From: Lorenzo Colitti @ 2018-07-07  7:31 UTC (permalink / raw)
  To: netdev
  Cc: astrachan, subashab, eric.dumazet, davem, Lorenzo Colitti, David Ahern

When tcp_diag_destroy closes a TCP_NEW_SYN_RECV socket, it first
frees it by calling inet_csk_reqsk_queue_drop_and_and_put in
tcp_abort, and then frees it again by calling sock_gen_put.

Since tcp_abort only has one caller, and all the other codepaths
in tcp_abort don't free the socket, just remove the free in that
function.

Cc: David Ahern <dsa@cumulusnetworks.com>
Tested: passes Android sock_diag_test.py, which exercises this codepath
Fixes: d7226c7a4dd1 ("net: diag: Fix refcnt leak in error path destroying socket")
Signed-off-by: Lorenzo Colitti <lorenzo@google.com>
---
 net/ipv4/tcp.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index e7b53d2a97..c959bb6ea4 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -3720,8 +3720,7 @@ int tcp_abort(struct sock *sk, int err)
 			struct request_sock *req = inet_reqsk(sk);
 
 			local_bh_disable();
-			inet_csk_reqsk_queue_drop_and_put(req->rsk_listener,
-							  req);
+			inet_csk_reqsk_queue_drop(req->rsk_listener, req);
 			local_bh_enable();
 			return 0;
 		}
-- 
2.18.0.203.gfac676dfb9-goog

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

end of thread, other threads:[~2018-07-09 16:21 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-07  7:31 [PATCH net] net: diag: Don't double-free TCP_NEW_SYN_RECV sockets in tcp_abort Lorenzo Colitti
2018-07-07 13:11 ` David Miller
2018-07-07 13:29   ` Eric Dumazet
2018-07-07 13:58     ` Eric Dumazet
2018-07-09  4:53     ` Lorenzo Colitti
2018-07-09 14:59       ` David Ahern
2018-07-09 15:17         ` Eric Dumazet
2018-07-09 16:14           ` David Ahern
2018-07-09 16:21             ` Eric Dumazet
2018-07-07 13:33   ` David Ahern
2018-07-07 13:45     ` Eric Dumazet
2018-07-07 13:51       ` Eric Dumazet
2018-07-07 13:56         ` David Ahern
2018-07-07 14:16           ` Eric Dumazet
2018-07-07 14:19             ` Eric Dumazet
2018-07-09  5:24           ` Lorenzo Colitti
2018-07-09 15:00             ` David Ahern
2018-07-07 13:28 ` Eric Dumazet
2018-07-07 22:07 ` David Ahern
2018-07-08  1:57 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.