Message ID | e22492f139a67c34c639737cc54b3a57a8c78ef3.1742557254.git.pabeni@redhat.com (mailing list archive) |
---|---|
State | New |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | udp_tunnel: GRO optimization follow-up | expand |
Paolo Abeni wrote: > UDP tunnel sockets owned by the kernel are never disconnected/rebound > after setup_udp_tunnel_sock(), but sockets owned by the user-space could > go through such changes after being matching the criteria to enable > the GRO lookup optimization, breaking them. > > Explicitly prevent user-space owned sockets from leveraging such > optimization. UDP tunnel sockets are generally initialized with udp_sock_create, which calls sock_create_kern. > Signed-off-by: Paolo Abeni <pabeni@redhat.com> Reviewed-by: Willem de Bruijn <willemb@google.com>
diff --git a/net/ipv4/udp_tunnel_core.c b/net/ipv4/udp_tunnel_core.c index aa9016619c25a..2326548997d3f 100644 --- a/net/ipv4/udp_tunnel_core.c +++ b/net/ipv4/udp_tunnel_core.c @@ -92,7 +92,8 @@ void setup_udp_tunnel_sock(struct net *net, struct socket *sock, udp_tunnel_update_gro_rcv(sk, true); - if (!sk->sk_dport && !sk->sk_bound_dev_if && sk_saddr_any(sk)) + if (!sk->sk_dport && !sk->sk_bound_dev_if && sk_saddr_any(sk) && + sk->sk_kern_sock) udp_tunnel_update_gro_lookup(net, sk, true); } EXPORT_SYMBOL_GPL(setup_udp_tunnel_sock);
UDP tunnel sockets owned by the kernel are never disconnected/rebound after setup_udp_tunnel_sock(), but sockets owned by the user-space could go through such changes after being matching the criteria to enable the GRO lookup optimization, breaking them. Explicitly prevent user-space owned sockets from leveraging such optimization. Signed-off-by: Paolo Abeni <pabeni@redhat.com> --- net/ipv4/udp_tunnel_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)