Skip to content

Commit b62a59c

Browse files
edumazetkuba-moo
authored andcommitted
tcp: use dst_dev_rcu() in tcp_fastopen_active_disable_ofo_check()
Use RCU to avoid a pair of atomic operations and a potential UAF on dst_dev()->flags. Signed-off-by: Eric Dumazet <[email protected]> Reviewed-by: David Ahern <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 50c127a commit b62a59c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

net/ipv4/tcp_fastopen.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -576,11 +576,12 @@ void tcp_fastopen_active_disable_ofo_check(struct sock *sk)
576576
}
577577
} else if (tp->syn_fastopen_ch &&
578578
atomic_read(&sock_net(sk)->ipv4.tfo_active_disable_times)) {
579-
dst = sk_dst_get(sk);
580-
dev = dst ? dst_dev(dst) : NULL;
579+
rcu_read_lock();
580+
dst = __sk_dst_get(sk);
581+
dev = dst ? dst_dev_rcu(dst) : NULL;
581582
if (!(dev && (dev->flags & IFF_LOOPBACK)))
582583
atomic_set(&sock_net(sk)->ipv4.tfo_active_disable_times, 0);
583-
dst_release(dst);
584+
rcu_read_unlock();
584585
}
585586
}
586587

0 commit comments

Comments
 (0)