Skip to content

Commit c76a032

Browse files
edumazetdavem330
authored andcommitted
net: annotate data-race around sk->sk_txrehash
sk_getsockopt() runs locklessly. This means sk->sk_txrehash can be read while other threads are changing its value. Other locations were handled in commit cb6cd2c ("tcp: Change SYN ACK retransmit behaviour to account for rehash") Fixes: 2685924 ("txhash: Add socket option to control TX hash rethink behavior") Signed-off-by: Eric Dumazet <[email protected]> Cc: Akhmat Karakotov <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent fe11fdc commit c76a032

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

net/core/sock.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1534,7 +1534,9 @@ int sk_setsockopt(struct sock *sk, int level, int optname,
15341534
}
15351535
if ((u8)val == SOCK_TXREHASH_DEFAULT)
15361536
val = READ_ONCE(sock_net(sk)->core.sysctl_txrehash);
1537-
/* Paired with READ_ONCE() in tcp_rtx_synack() */
1537+
/* Paired with READ_ONCE() in tcp_rtx_synack()
1538+
* and sk_getsockopt().
1539+
*/
15381540
WRITE_ONCE(sk->sk_txrehash, (u8)val);
15391541
break;
15401542

@@ -1978,7 +1980,8 @@ int sk_getsockopt(struct sock *sk, int level, int optname,
19781980
break;
19791981

19801982
case SO_TXREHASH:
1981-
v.val = sk->sk_txrehash;
1983+
/* Paired with WRITE_ONCE() in sk_setsockopt() */
1984+
v.val = READ_ONCE(sk->sk_txrehash);
19821985
break;
19831986

19841987
default:

0 commit comments

Comments
 (0)