diff options
author | Eric Dumazet <edumazet@google.com> | 2019-10-10 23:17:38 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-10-13 13:13:08 -0400 |
commit | d983ea6f16b835dcde2ee9a58a1e764ce68bfccc (patch) | |
tree | 2bc283f36a6769e0247c49420f0c2149f147f08c /net/ipv4/inet_connection_sock.c | |
parent | 8caf8a91f34d55e8e3b1355ee8d658cb472146e2 (diff) |
tcp: add rcu protection around tp->fastopen_rsk
Both tcp_v4_err() and tcp_v6_err() do the following operations
while they do not own the socket lock :
fastopen = tp->fastopen_rsk;
snd_una = fastopen ? tcp_rsk(fastopen)->snt_isn : tp->snd_una;
The problem is that without appropriate barrier, the compiler
might reload tp->fastopen_rsk and trigger a NULL deref.
request sockets are protected by RCU, we can simply add
the missing annotations and barriers to solve the issue.
Fixes: 168a8f58059a ("tcp: TCP Fast Open Server - main code path")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/inet_connection_sock.c')
-rw-r--r-- | net/ipv4/inet_connection_sock.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c index dbcf34ec8dd2..eb30fc1770de 100644 --- a/net/ipv4/inet_connection_sock.c +++ b/net/ipv4/inet_connection_sock.c | |||
@@ -906,7 +906,7 @@ static void inet_child_forget(struct sock *sk, struct request_sock *req, | |||
906 | percpu_counter_inc(sk->sk_prot->orphan_count); | 906 | percpu_counter_inc(sk->sk_prot->orphan_count); |
907 | 907 | ||
908 | if (sk->sk_protocol == IPPROTO_TCP && tcp_rsk(req)->tfo_listener) { | 908 | if (sk->sk_protocol == IPPROTO_TCP && tcp_rsk(req)->tfo_listener) { |
909 | BUG_ON(tcp_sk(child)->fastopen_rsk != req); | 909 | BUG_ON(rcu_access_pointer(tcp_sk(child)->fastopen_rsk) != req); |
910 | BUG_ON(sk != req->rsk_listener); | 910 | BUG_ON(sk != req->rsk_listener); |
911 | 911 | ||
912 | /* Paranoid, to prevent race condition if | 912 | /* Paranoid, to prevent race condition if |
@@ -915,7 +915,7 @@ static void inet_child_forget(struct sock *sk, struct request_sock *req, | |||
915 | * Also to satisfy an assertion in | 915 | * Also to satisfy an assertion in |
916 | * tcp_v4_destroy_sock(). | 916 | * tcp_v4_destroy_sock(). |
917 | */ | 917 | */ |
918 | tcp_sk(child)->fastopen_rsk = NULL; | 918 | RCU_INIT_POINTER(tcp_sk(child)->fastopen_rsk, NULL); |
919 | } | 919 | } |
920 | inet_csk_destroy_sock(child); | 920 | inet_csk_destroy_sock(child); |
921 | } | 921 | } |