Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4177f54

Browse files
q2vendavem330
authored andcommitted
tcp: Fix data-races around sysctl_tcp_migrate_req.
While reading sysctl_tcp_migrate_req, it can be changed concurrently. Thus, we need to add READ_ONCE() to its readers. Fixes: f9ac779 ("net: Introduce net.ipv4.tcp_migrate_req.") Signed-off-by: Kuniyuki Iwashima <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f2e383b commit 4177f54

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

net/core/sock_reuseport.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ void reuseport_stop_listen_sock(struct sock *sk)
387387
prog = rcu_dereference_protected(reuse->prog,
388388
lockdep_is_held(&reuseport_lock));
389389

390-
if (sock_net(sk)->ipv4.sysctl_tcp_migrate_req ||
390+
if (READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_migrate_req) ||
391391
(prog && prog->expected_attach_type == BPF_SK_REUSEPORT_SELECT_OR_MIGRATE)) {
392392
/* Migration capable, move sk from the listening section
393393
* to the closed section.
@@ -545,7 +545,7 @@ struct sock *reuseport_migrate_sock(struct sock *sk,
545545
hash = migrating_sk->sk_hash;
546546
prog = rcu_dereference(reuse->prog);
547547
if (!prog || prog->expected_attach_type != BPF_SK_REUSEPORT_SELECT_OR_MIGRATE) {
548-
if (sock_net(sk)->ipv4.sysctl_tcp_migrate_req)
548+
if (READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_migrate_req))
549549
goto select_by_hash;
550550
goto failure;
551551
}

0 commit comments

Comments
 (0)