All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] tcp: fix a lockdep issue in tcp_fastopen_reset_cipher()
@ 2017-11-02 18:53 Eric Dumazet
  2017-11-02 19:55 ` Christoph Paasch
  2017-11-03  6:54 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Eric Dumazet @ 2017-11-02 18:53 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Yuchung Cheng, Christoph Paasch

From: Eric Dumazet <edumazet@google.com>

icsk_accept_queue.fastopenq.lock is only fully initialized at listen()
time.

LOCKDEP is not happy if we attempt a spin_lock_bh() on it, because
of missing annotation. (Although kernel runs just fine)

Lets use net->ipv4.tcp_fastopen_ctx_lock to protect ctx access.

Fixes: 1fba70e5b6be ("tcp: socket option to set TCP fast open key")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Yuchung Cheng <ycheng@google.com>
Cc: Christoph Paasch <cpaasch@apple.com>
---
 net/ipv4/tcp_fastopen.c |    8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/net/ipv4/tcp_fastopen.c b/net/ipv4/tcp_fastopen.c
index e0a4b56644aa0f8ccd384644fde7e4841da29d3f..91762be58accaed7d8974e723b580fb3d7922fca 100644
--- a/net/ipv4/tcp_fastopen.c
+++ b/net/ipv4/tcp_fastopen.c
@@ -92,20 +92,18 @@ error:		kfree(ctx);
 	memcpy(ctx->key, key, len);
 
 
+	spin_lock(&net->ipv4.tcp_fastopen_ctx_lock);
 	if (sk) {
 		q = &inet_csk(sk)->icsk_accept_queue.fastopenq;
-		spin_lock_bh(&q->lock);
 		octx = rcu_dereference_protected(q->ctx,
-						 lockdep_is_held(&q->lock));
+			lockdep_is_held(&net->ipv4.tcp_fastopen_ctx_lock));
 		rcu_assign_pointer(q->ctx, ctx);
-		spin_unlock_bh(&q->lock);
 	} else {
-		spin_lock(&net->ipv4.tcp_fastopen_ctx_lock);
 		octx = rcu_dereference_protected(net->ipv4.tcp_fastopen_ctx,
 			lockdep_is_held(&net->ipv4.tcp_fastopen_ctx_lock));
 		rcu_assign_pointer(net->ipv4.tcp_fastopen_ctx, ctx);
-		spin_unlock(&net->ipv4.tcp_fastopen_ctx_lock);
 	}
+	spin_unlock(&net->ipv4.tcp_fastopen_ctx_lock);
 
 	if (octx)
 		call_rcu(&octx->rcu, tcp_fastopen_ctx_free);

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

* Re: [PATCH net-next] tcp: fix a lockdep issue in tcp_fastopen_reset_cipher()
  2017-11-02 18:53 [PATCH net-next] tcp: fix a lockdep issue in tcp_fastopen_reset_cipher() Eric Dumazet
@ 2017-11-02 19:55 ` Christoph Paasch
  2017-11-03  6:54 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Christoph Paasch @ 2017-11-02 19:55 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: David Miller, netdev, Yuchung Cheng

On 02/11/17 - 11:53:04, Eric Dumazet wrote:
> From: Eric Dumazet <edumazet@google.com>
> 
> icsk_accept_queue.fastopenq.lock is only fully initialized at listen()
> time.
> 
> LOCKDEP is not happy if we attempt a spin_lock_bh() on it, because
> of missing annotation. (Although kernel runs just fine)
> 
> Lets use net->ipv4.tcp_fastopen_ctx_lock to protect ctx access.
> 
> Fixes: 1fba70e5b6be ("tcp: socket option to set TCP fast open key")
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Yuchung Cheng <ycheng@google.com>
> Cc: Christoph Paasch <cpaasch@apple.com>
> ---
>  net/ipv4/tcp_fastopen.c |    8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)

Reviewed-by: Christoph Paasch <cpaasch@apple.com>

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

* Re: [PATCH net-next] tcp: fix a lockdep issue in tcp_fastopen_reset_cipher()
  2017-11-02 18:53 [PATCH net-next] tcp: fix a lockdep issue in tcp_fastopen_reset_cipher() Eric Dumazet
  2017-11-02 19:55 ` Christoph Paasch
@ 2017-11-03  6:54 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2017-11-03  6:54 UTC (permalink / raw)
  To: eric.dumazet; +Cc: netdev, ycheng, cpaasch

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Thu, 02 Nov 2017 11:53:04 -0700

> From: Eric Dumazet <edumazet@google.com>
> 
> icsk_accept_queue.fastopenq.lock is only fully initialized at listen()
> time.
> 
> LOCKDEP is not happy if we attempt a spin_lock_bh() on it, because
> of missing annotation. (Although kernel runs just fine)
> 
> Lets use net->ipv4.tcp_fastopen_ctx_lock to protect ctx access.
> 
> Fixes: 1fba70e5b6be ("tcp: socket option to set TCP fast open key")
> Signed-off-by: Eric Dumazet <edumazet@google.com>

Applied.

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

end of thread, other threads:[~2017-11-03  6:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-02 18:53 [PATCH net-next] tcp: fix a lockdep issue in tcp_fastopen_reset_cipher() Eric Dumazet
2017-11-02 19:55 ` Christoph Paasch
2017-11-03  6:54 ` 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.