inet: implement lockless IP_TOS
Some reads of inet->tos are racy. Add needed READ_ONCE() annotations and convert IP_TOS option lockless. v2: missing changes in include/net/route.h (David Ahern) Signed-off-by: Eric Dumazet <edumazet@google.com> Reviewed-by: David Ahern <dsahern@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
		
				
					committed by
					
						 David S. Miller
						David S. Miller
					
				
			
			
				
	
			
			
			
						parent
						
							ceaa714138
						
					
				
				
					commit
					e08d0b3d17
				
			| @@ -734,11 +734,11 @@ static int mptcp_setsockopt_v4_set_tos(struct mptcp_sock *msk, int optname, | ||||
| 
 | ||||
| 	lock_sock(sk); | ||||
| 	sockopt_seq_inc(msk); | ||||
| 	val = inet_sk(sk)->tos; | ||||
| 	val = READ_ONCE(inet_sk(sk)->tos); | ||||
| 	mptcp_for_each_subflow(msk, subflow) { | ||||
| 		struct sock *ssk = mptcp_subflow_tcp_sock(subflow); | ||||
| 
 | ||||
| 		__ip_sock_set_tos(ssk, val); | ||||
| 		ip_sock_set_tos(ssk, val); | ||||
| 	} | ||||
| 	release_sock(sk); | ||||
| 
 | ||||
| @@ -1343,7 +1343,7 @@ static int mptcp_getsockopt_v4(struct mptcp_sock *msk, int optname, | ||||
| 
 | ||||
| 	switch (optname) { | ||||
| 	case IP_TOS: | ||||
| 		return mptcp_put_int_option(msk, optval, optlen, inet_sk(sk)->tos); | ||||
| 		return mptcp_put_int_option(msk, optval, optlen, READ_ONCE(inet_sk(sk)->tos)); | ||||
| 	} | ||||
| 
 | ||||
| 	return -EOPNOTSUPP; | ||||
| @@ -1411,7 +1411,7 @@ static void sync_socket_options(struct mptcp_sock *msk, struct sock *ssk) | ||||
| 	ssk->sk_bound_dev_if = sk->sk_bound_dev_if; | ||||
| 	ssk->sk_incoming_cpu = sk->sk_incoming_cpu; | ||||
| 	ssk->sk_ipv6only = sk->sk_ipv6only; | ||||
| 	__ip_sock_set_tos(ssk, inet_sk(sk)->tos); | ||||
| 	ip_sock_set_tos(ssk, inet_sk(sk)->tos); | ||||
| 
 | ||||
| 	if (sk->sk_userlocks & tx_rx_locks) { | ||||
| 		ssk->sk_userlocks |= sk->sk_userlocks & tx_rx_locks; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user