summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2017-11-02 11:53:04 -0700
committerDavid S. Miller <davem@davemloft.net>2017-11-03 15:51:39 +0900
commit9eba9353388da7bfac9694dfe94c15365d49ebd6 (patch)
tree56d6e257cef00eff4bb0e2af027509011615e4fa /net
parent8c01c4f896aa3404af948880dcb29a2d51c833dc (diff)
downloadlinux-9eba9353388da7bfac9694dfe94c15365d49ebd6.tar.gz
linux-9eba9353388da7bfac9694dfe94c15365d49ebd6.tar.bz2
linux-9eba9353388da7bfac9694dfe94c15365d49ebd6.zip
tcp: fix a lockdep issue in tcp_fastopen_reset_cipher()
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> Reviewed-by: Christoph Paasch <cpaasch@apple.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/ipv4/tcp_fastopen.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/net/ipv4/tcp_fastopen.c b/net/ipv4/tcp_fastopen.c
index e0a4b56644aa..91762be58acc 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);