Skip to content

Commit bc2b881

Browse files
edumazetgregkh
authored andcommitted
tcp: use dst_dev_rcu() in tcp_fastopen_active_disable_ofo_check()
[ Upstream commit b62a59c ] 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]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 047c088 commit bc2b881

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
@@ -575,11 +575,12 @@ void tcp_fastopen_active_disable_ofo_check(struct sock *sk)
575575
}
576576
} else if (tp->syn_fastopen_ch &&
577577
atomic_read(&sock_net(sk)->ipv4.tfo_active_disable_times)) {
578-
dst = sk_dst_get(sk);
579-
dev = dst ? dst_dev(dst) : NULL;
578+
rcu_read_lock();
579+
dst = __sk_dst_get(sk);
580+
dev = dst ? dst_dev_rcu(dst) : NULL;
580581
if (!(dev && (dev->flags & IFF_LOOPBACK)))
581582
atomic_set(&sock_net(sk)->ipv4.tfo_active_disable_times, 0);
582-
dst_release(dst);
583+
rcu_read_unlock();
583584
}
584585
}
585586

0 commit comments

Comments
 (0)