mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-20 13:24:17 -04:00
Merge branch 'tcp-annotate-data-races-around-icsk_retransmits-and-icsk_probes_out'
Eric Dumazet says: ==================== tcp: annotate data-races around icsk_retransmits and icsk_probes_out icsk->icsk_retransmits is read locklessly from inet_sk_diag_fill(), tcp_get_timestamping_opt_stats, get_tcp4_sock() and get_tcp6_sock(). icsk->icsk_probes_out is read locklessly from inet_sk_diag_fill(), get_tcp4_sock() and get_tcp6_sock(). Add corresponding READ_ONCE()/WRITE_ONCE() annotations. ==================== Link: https://patch.msgid.link/20250822091727.835869-1-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
@@ -313,17 +313,17 @@ int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk,
|
||||
icsk_pending == ICSK_TIME_REO_TIMEOUT ||
|
||||
icsk_pending == ICSK_TIME_LOSS_PROBE) {
|
||||
r->idiag_timer = 1;
|
||||
r->idiag_retrans = icsk->icsk_retransmits;
|
||||
r->idiag_retrans = READ_ONCE(icsk->icsk_retransmits);
|
||||
r->idiag_expires =
|
||||
jiffies_delta_to_msecs(icsk_timeout(icsk) - jiffies);
|
||||
} else if (icsk_pending == ICSK_TIME_PROBE0) {
|
||||
r->idiag_timer = 4;
|
||||
r->idiag_retrans = icsk->icsk_probes_out;
|
||||
r->idiag_retrans = READ_ONCE(icsk->icsk_probes_out);
|
||||
r->idiag_expires =
|
||||
jiffies_delta_to_msecs(icsk_timeout(icsk) - jiffies);
|
||||
} else if (timer_pending(&sk->sk_timer)) {
|
||||
r->idiag_timer = 2;
|
||||
r->idiag_retrans = icsk->icsk_probes_out;
|
||||
r->idiag_retrans = READ_ONCE(icsk->icsk_probes_out);
|
||||
r->idiag_expires =
|
||||
jiffies_delta_to_msecs(sk->sk_timer.expires - jiffies);
|
||||
}
|
||||
|
||||
@@ -3376,7 +3376,7 @@ int tcp_disconnect(struct sock *sk, int flags)
|
||||
WRITE_ONCE(tp->write_seq, seq);
|
||||
|
||||
icsk->icsk_backoff = 0;
|
||||
icsk->icsk_probes_out = 0;
|
||||
WRITE_ONCE(icsk->icsk_probes_out, 0);
|
||||
icsk->icsk_probes_tstamp = 0;
|
||||
icsk->icsk_rto = TCP_TIMEOUT_INIT;
|
||||
WRITE_ONCE(icsk->icsk_rto_min, TCP_RTO_MIN);
|
||||
@@ -4346,7 +4346,8 @@ struct sk_buff *tcp_get_timestamping_opt_stats(const struct sock *sk,
|
||||
nla_put_u32(stats, TCP_NLA_REORDERING, tp->reordering);
|
||||
nla_put_u32(stats, TCP_NLA_MIN_RTT, tcp_min_rtt(tp));
|
||||
|
||||
nla_put_u8(stats, TCP_NLA_RECUR_RETRANS, inet_csk(sk)->icsk_retransmits);
|
||||
nla_put_u8(stats, TCP_NLA_RECUR_RETRANS,
|
||||
READ_ONCE(inet_csk(sk)->icsk_retransmits));
|
||||
nla_put_u8(stats, TCP_NLA_DELIVERY_RATE_APP_LMT, !!tp->rate_app_limited);
|
||||
nla_put_u32(stats, TCP_NLA_SND_SSTHRESH, tp->snd_ssthresh);
|
||||
nla_put_u32(stats, TCP_NLA_DELIVERED, tp->delivered);
|
||||
|
||||
@@ -2569,7 +2569,7 @@ static bool tcp_try_undo_loss(struct sock *sk, bool frto_undo)
|
||||
if (frto_undo)
|
||||
NET_INC_STATS(sock_net(sk),
|
||||
LINUX_MIB_TCPSPURIOUSRTOS);
|
||||
inet_csk(sk)->icsk_retransmits = 0;
|
||||
WRITE_ONCE(inet_csk(sk)->icsk_retransmits, 0);
|
||||
if (tcp_is_non_sack_preventing_reopen(sk))
|
||||
return true;
|
||||
if (frto_undo || tcp_is_sack(tp)) {
|
||||
@@ -3851,7 +3851,7 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag)
|
||||
|
||||
if (after(ack, prior_snd_una)) {
|
||||
flag |= FLAG_SND_UNA_ADVANCED;
|
||||
icsk->icsk_retransmits = 0;
|
||||
WRITE_ONCE(icsk->icsk_retransmits, 0);
|
||||
|
||||
#if IS_ENABLED(CONFIG_TLS_DEVICE)
|
||||
if (static_branch_unlikely(&clean_acked_data_enabled.key))
|
||||
@@ -3913,7 +3913,7 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag)
|
||||
* log. Something worked...
|
||||
*/
|
||||
WRITE_ONCE(sk->sk_err_soft, 0);
|
||||
icsk->icsk_probes_out = 0;
|
||||
WRITE_ONCE(icsk->icsk_probes_out, 0);
|
||||
tp->rcv_tstamp = tcp_jiffies32;
|
||||
if (!prior_packets)
|
||||
goto no_queue;
|
||||
@@ -6636,7 +6636,7 @@ static void tcp_rcv_synrecv_state_fastopen(struct sock *sk)
|
||||
tcp_try_undo_recovery(sk);
|
||||
|
||||
tcp_update_rto_time(tp);
|
||||
inet_csk(sk)->icsk_retransmits = 0;
|
||||
WRITE_ONCE(inet_csk(sk)->icsk_retransmits, 0);
|
||||
/* In tcp_fastopen_synack_timer() on the first SYNACK RTO we set
|
||||
* retrans_stamp but don't enter CA_Loss, so in case that happened we
|
||||
* need to zero retrans_stamp here to prevent spurious
|
||||
|
||||
@@ -2958,9 +2958,9 @@ static void get_tcp4_sock(struct sock *sk, struct seq_file *f, int i)
|
||||
rx_queue,
|
||||
timer_active,
|
||||
jiffies_delta_to_clock_t(timer_expires - jiffies),
|
||||
icsk->icsk_retransmits,
|
||||
READ_ONCE(icsk->icsk_retransmits),
|
||||
from_kuid_munged(seq_user_ns(f), sk_uid(sk)),
|
||||
icsk->icsk_probes_out,
|
||||
READ_ONCE(icsk->icsk_probes_out),
|
||||
sock_i_ino(sk),
|
||||
refcount_read(&sk->sk_refcnt), sk,
|
||||
jiffies_to_clock_t(icsk->icsk_rto),
|
||||
|
||||
@@ -3956,7 +3956,7 @@ static void tcp_connect_init(struct sock *sk)
|
||||
WRITE_ONCE(tp->copied_seq, tp->rcv_nxt);
|
||||
|
||||
inet_csk(sk)->icsk_rto = tcp_timeout_init(sk);
|
||||
inet_csk(sk)->icsk_retransmits = 0;
|
||||
WRITE_ONCE(inet_csk(sk)->icsk_retransmits, 0);
|
||||
tcp_clear_retrans(tp);
|
||||
}
|
||||
|
||||
@@ -4394,13 +4394,13 @@ void tcp_send_probe0(struct sock *sk)
|
||||
|
||||
if (tp->packets_out || tcp_write_queue_empty(sk)) {
|
||||
/* Cancel probe timer, if it is not required. */
|
||||
icsk->icsk_probes_out = 0;
|
||||
WRITE_ONCE(icsk->icsk_probes_out, 0);
|
||||
icsk->icsk_backoff = 0;
|
||||
icsk->icsk_probes_tstamp = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
icsk->icsk_probes_out++;
|
||||
WRITE_ONCE(icsk->icsk_probes_out, icsk->icsk_probes_out + 1);
|
||||
if (err <= 0) {
|
||||
if (icsk->icsk_backoff < READ_ONCE(net->ipv4.sysctl_tcp_retries2))
|
||||
icsk->icsk_backoff++;
|
||||
|
||||
@@ -392,7 +392,7 @@ static void tcp_probe_timer(struct sock *sk)
|
||||
int max_probes;
|
||||
|
||||
if (tp->packets_out || !skb) {
|
||||
icsk->icsk_probes_out = 0;
|
||||
WRITE_ONCE(icsk->icsk_probes_out, 0);
|
||||
icsk->icsk_probes_tstamp = 0;
|
||||
return;
|
||||
}
|
||||
@@ -444,7 +444,7 @@ static void tcp_update_rto_stats(struct sock *sk)
|
||||
tp->total_rto_recoveries++;
|
||||
tp->rto_stamp = tcp_time_stamp_ms(tp);
|
||||
}
|
||||
icsk->icsk_retransmits++;
|
||||
WRITE_ONCE(icsk->icsk_retransmits, icsk->icsk_retransmits + 1);
|
||||
tp->total_rto++;
|
||||
}
|
||||
|
||||
@@ -839,7 +839,7 @@ static void tcp_keepalive_timer(struct timer_list *t)
|
||||
goto out;
|
||||
}
|
||||
if (tcp_write_wakeup(sk, LINUX_MIB_TCPKEEPALIVE) <= 0) {
|
||||
icsk->icsk_probes_out++;
|
||||
WRITE_ONCE(icsk->icsk_probes_out, icsk->icsk_probes_out + 1);
|
||||
elapsed = keepalive_intvl_when(tp);
|
||||
} else {
|
||||
/* If keepalive was lost due to local congestion,
|
||||
|
||||
@@ -2230,9 +2230,9 @@ static void get_tcp6_sock(struct seq_file *seq, struct sock *sp, int i)
|
||||
rx_queue,
|
||||
timer_active,
|
||||
jiffies_delta_to_clock_t(timer_expires - jiffies),
|
||||
icsk->icsk_retransmits,
|
||||
READ_ONCE(icsk->icsk_retransmits),
|
||||
from_kuid_munged(seq_user_ns(seq), sk_uid(sp)),
|
||||
icsk->icsk_probes_out,
|
||||
READ_ONCE(icsk->icsk_probes_out),
|
||||
sock_i_ino(sp),
|
||||
refcount_read(&sp->sk_refcnt), sp,
|
||||
jiffies_to_clock_t(icsk->icsk_rto),
|
||||
|
||||
@@ -2587,7 +2587,8 @@ static void __mptcp_retrans(struct sock *sk)
|
||||
if (mptcp_data_fin_enabled(msk)) {
|
||||
struct inet_connection_sock *icsk = inet_csk(sk);
|
||||
|
||||
icsk->icsk_retransmits++;
|
||||
WRITE_ONCE(icsk->icsk_retransmits,
|
||||
icsk->icsk_retransmits + 1);
|
||||
mptcp_set_datafin_timeout(sk);
|
||||
mptcp_send_ack(msk);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user