Skip to content

Commit 348b81b

Browse files
edumazetkuba-moo
authored andcommitted
tcp: annotate data-races around tp->tcp_tx_delay
do_tcp_getsockopt() reads tp->tcp_tx_delay while another cpu might change its value. Fixes: a842fe1 ("tcp: add optional per socket transmit delay") Signed-off-by: Eric Dumazet <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent ac52864 commit 348b81b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

net/ipv4/tcp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3674,7 +3674,7 @@ int do_tcp_setsockopt(struct sock *sk, int level, int optname,
36743674
case TCP_TX_DELAY:
36753675
if (val)
36763676
tcp_enable_tx_delay();
3677-
tp->tcp_tx_delay = val;
3677+
WRITE_ONCE(tp->tcp_tx_delay, val);
36783678
break;
36793679
default:
36803680
err = -ENOPROTOOPT;
@@ -4154,7 +4154,7 @@ int do_tcp_getsockopt(struct sock *sk, int level,
41544154
break;
41554155

41564156
case TCP_TX_DELAY:
4157-
val = tp->tcp_tx_delay;
4157+
val = READ_ONCE(tp->tcp_tx_delay);
41584158
break;
41594159

41604160
case TCP_TIMESTAMP:

0 commit comments

Comments
 (0)