Netdev List
 help / color / mirror / Atom feed
* [PATCH net] tcp/dccp: fix lockdep splat in inet_csk_route_req()
@ 2017-10-22 19:33 Eric Dumazet
  2017-10-23  4:46 ` David Miller
  2017-10-23  9:56 ` [tcp/dccp] 81e5391ca7: WARNING:suspicious_RCU_usage kernel test robot
  0 siblings, 2 replies; 12+ messages in thread
From: Eric Dumazet @ 2017-10-22 19:33 UTC (permalink / raw)
  To: David Miller; +Cc: netdev

From: Eric Dumazet <edumazet@google.com>

This patch fixes the following lockdep splat in inet_csk_route_req()

  lockdep_rcu_suspicious
  inet_csk_route_req
  tcp_v4_send_synack
  tcp_rtx_synack
  inet_rtx_syn_ack
  tcp_fastopen_synack_time
  tcp_retransmit_timer
  tcp_write_timer_handler
  tcp_write_timer
  call_timer_fn

Thread running inet_csk_route_req() owns a reference on the request
socket, so we have the guarantee ireq->ireq_opt wont be changed or
freed.

lockdep can enforce this invariant for us.

Fixes: c92e8c02fe66 ("tcp/dccp: fix ireq->opt races")
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 net/ipv4/inet_connection_sock.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
index 5ec9136a7c36933cb36e5cd50058eb6cf189a7c3..18cd2eae758ff1a9d8a736e143417c7007b99067 100644
--- a/net/ipv4/inet_connection_sock.c
+++ b/net/ipv4/inet_connection_sock.c
@@ -543,7 +543,8 @@ struct dst_entry *inet_csk_route_req(const struct sock *sk,
 	struct ip_options_rcu *opt;
 	struct rtable *rt;
 
-	opt = rcu_dereference(ireq->ireq_opt);
+	opt = rcu_dereference_protected(ireq->ireq_opt,
+					refcount_read(&req->rsk_refcnt) > 0);
 	flowi4_init_output(fl4, ireq->ir_iif, ireq->ir_mark,
 			   RT_CONN_FLAGS(sk), RT_SCOPE_UNIVERSE,
 			   sk->sk_protocol, inet_sk_flowi_flags(sk),

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

end of thread, other threads:[~2017-10-26  8:42 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-22 19:33 [PATCH net] tcp/dccp: fix lockdep splat in inet_csk_route_req() Eric Dumazet
2017-10-23  4:46 ` David Miller
2017-10-23  9:56 ` [tcp/dccp] 81e5391ca7: WARNING:suspicious_RCU_usage kernel test robot
2017-10-23 15:02   ` [PATCH net] tcp/dccp: fix again lockdep splat in inet_csk_route_req() Eric Dumazet
2017-10-23 22:46     ` Eric Dumazet
2017-10-23 23:15     ` [PATCH v2 net] tcp/dccp: fix other lockdep splats accessing ireq_opt Eric Dumazet
2017-10-24  9:56       ` David Miller
2017-10-24 15:18         ` Eric Dumazet
2017-10-24 12:17       ` kbuild test robot
2017-10-24 12:27       ` kbuild test robot
2017-10-24 15:20       ` [PATCH v3 " Eric Dumazet
2017-10-26  8:42         ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox