Skip to content

Commit 8607d55

Browse files
edumazetgregkh
authored andcommitted
tcp: fastopen: tcp_connect() must refresh the route
[ Upstream commit 8ba60924710cde564a3905588b6219741d6356d0 ] With new TCP_FASTOPEN_CONNECT socket option, there is a possibility to call tcp_connect() while socket sk_dst_cache is either NULL or invalid. +0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 4 +0 fcntl(4, F_SETFL, O_RDWR|O_NONBLOCK) = 0 +0 setsockopt(4, SOL_TCP, TCP_FASTOPEN_CONNECT, [1], 4) = 0 +0 connect(4, ..., ...) = 0 << sk->sk_dst_cache becomes obsolete, or even set to NULL >> +1 sendto(4, ..., 1000, MSG_FASTOPEN, ..., ...) = 1000 We need to refresh the route otherwise bad things can happen, especially when syzkaller is running on the host :/ Fixes: 19f6d3f3c8422 ("net/tcp-fastopen: Add new API support") Reported-by: Dmitry Vyukov <dvyukov@google.com> Signed-off-by: Eric Dumazet <edumazet@google.com> Cc: Wei Wang <weiwan@google.com> Cc: Yuchung Cheng <ycheng@google.com> Acked-by: Wei Wang <weiwan@google.com> Acked-by: Yuchung Cheng <ycheng@google.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 40fc2b4 commit 8607d55

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

net/ipv4/tcp_output.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3256,6 +3256,9 @@ int tcp_connect(struct sock *sk)
32563256
struct sk_buff *buff;
32573257
int err;
32583258

3259+
if (inet_csk(sk)->icsk_af_ops->rebuild_header(sk))
3260+
return -EHOSTUNREACH; /* Routing failure or similar. */
3261+
32593262
tcp_connect_init(sk);
32603263

32613264
if (unlikely(tp->repair)) {

0 commit comments

Comments
 (0)