Skip to content

Commit b02f8fc

Browse files
edumazetgregkh
authored andcommitted
tcp: annotate data-races around rskq_defer_accept
[ Upstream commit ae488c7 ] do_tcp_getsockopt() reads rskq_defer_accept while another cpu might change its value. Fixes: 1da177e ("Linux-2.6.12-rc2") Signed-off-by: Eric Dumazet <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 17c3d75 commit b02f8fc

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

net/ipv4/tcp.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3700,9 +3700,9 @@ int do_tcp_setsockopt(struct sock *sk, int level, int optname,
37003700

37013701
case TCP_DEFER_ACCEPT:
37023702
/* Translate value in seconds to number of retransmits */
3703-
icsk->icsk_accept_queue.rskq_defer_accept =
3704-
secs_to_retrans(val, TCP_TIMEOUT_INIT / HZ,
3705-
TCP_RTO_MAX / HZ);
3703+
WRITE_ONCE(icsk->icsk_accept_queue.rskq_defer_accept,
3704+
secs_to_retrans(val, TCP_TIMEOUT_INIT / HZ,
3705+
TCP_RTO_MAX / HZ));
37063706
break;
37073707

37083708
case TCP_WINDOW_CLAMP:
@@ -4104,8 +4104,9 @@ int do_tcp_getsockopt(struct sock *sk, int level,
41044104
val = (val ? : READ_ONCE(net->ipv4.sysctl_tcp_fin_timeout)) / HZ;
41054105
break;
41064106
case TCP_DEFER_ACCEPT:
4107-
val = retrans_to_secs(icsk->icsk_accept_queue.rskq_defer_accept,
4108-
TCP_TIMEOUT_INIT / HZ, TCP_RTO_MAX / HZ);
4107+
val = READ_ONCE(icsk->icsk_accept_queue.rskq_defer_accept);
4108+
val = retrans_to_secs(val, TCP_TIMEOUT_INIT / HZ,
4109+
TCP_RTO_MAX / HZ);
41094110
break;
41104111
case TCP_WINDOW_CLAMP:
41114112
val = tp->window_clamp;

0 commit comments

Comments
 (0)