Commit 9eba9353 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

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: 1fba70e5 ("tcp: socket option to set TCP fast open key")
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Cc: Yuchung Cheng <ycheng@google.com>
Cc: Christoph Paasch <cpaasch@apple.com>
Reviewed-by: default avatarChristoph Paasch <cpaasch@apple.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8c01c4f8
...@@ -92,20 +92,18 @@ error: kfree(ctx); ...@@ -92,20 +92,18 @@ error: kfree(ctx);
memcpy(ctx->key, key, len); memcpy(ctx->key, key, len);
spin_lock(&net->ipv4.tcp_fastopen_ctx_lock);
if (sk) { if (sk) {
q = &inet_csk(sk)->icsk_accept_queue.fastopenq; q = &inet_csk(sk)->icsk_accept_queue.fastopenq;
spin_lock_bh(&q->lock);
octx = rcu_dereference_protected(q->ctx, 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); rcu_assign_pointer(q->ctx, ctx);
spin_unlock_bh(&q->lock);
} else { } else {
spin_lock(&net->ipv4.tcp_fastopen_ctx_lock);
octx = rcu_dereference_protected(net->ipv4.tcp_fastopen_ctx, octx = rcu_dereference_protected(net->ipv4.tcp_fastopen_ctx,
lockdep_is_held(&net->ipv4.tcp_fastopen_ctx_lock)); lockdep_is_held(&net->ipv4.tcp_fastopen_ctx_lock));
rcu_assign_pointer(net->ipv4.tcp_fastopen_ctx, ctx); 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) if (octx)
call_rcu(&octx->rcu, tcp_fastopen_ctx_free); call_rcu(&octx->rcu, tcp_fastopen_ctx_free);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment