Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4744432pxj; Wed, 12 May 2021 12:13:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxQAjDO9o2Hx4xCGwUIsFRyJ4WN5PGFSV58Yl0JVQjN70tU6EfbLLr1JQY++16gh74sVAMI X-Received: by 2002:aa7:c903:: with SMTP id b3mr45691251edt.296.1620846789545; Wed, 12 May 2021 12:13:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620846789; cv=none; d=google.com; s=arc-20160816; b=Y8UKY/v7LFnisiTw6ETcEyDrl8K71WuyEG4N8XIMi9tR6Y3crAp9O3V3dg/EwWgCyF FtwXPFJRNaQfY83mK7iJMI5W30XzFDTojcarpvHBGhCblC47E7B6Awho3pXfjM0RLq12 b8IAIBzuqsPi9/DyxpBkjJ3cjcERS4acboWVh7pWhkc4CMRkxVUKYHpWVj/WpnoEnEk5 m125g5pOjFUm4tTKH1MGxCJ3ERyM+7/2hwbqTv2MyR+yx7rHPW2ZXcwzqU8UMsv4VKeJ /qhDm+U+x2w77BkblNuGXBS5sFH6M82KzZAKj3bnDSoYGFfGzPQSRZSTpVH6EgE9QPbS 2u+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Eb5u9IMkbL13LeJApCVSUuni6f4zBhvaDNaCdOiRHUo=; b=A/Pf7HMktZCEFDZaQ+qJ7izGITC6su/d6dYeSme8wjLjURckcaXX4IiquXiBKy0AxR QJbjoevTEhGbQMSf3X9KFPqV4X9DOU9HdUzunkFIcR0JlctQFAeNhV72JVUc92UTB3wa Ktl1L+YEJ2Kkr7bd0pGPGUtc8qx1SHNe17DnEzqvQW16JRiZvXTjuJu5aQpKGVrAGtYN xOfRAge2UOkkc5MiHcDEu+szT4OPtk/5eTcS741KH6ROiRMMeCOXecHHPQQqv1UvzFII +EUw0aHRyUsuoRtLrlr56u2UjZLTZB9uSNnR05bd51V6Xh5CfRYTYErCewErIJFwTUoD Ve7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="EpifwE/q"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k9si852063eje.640.2021.05.12.12.12.45; Wed, 12 May 2021 12:13:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="EpifwE/q"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376357AbhELSye (ORCPT + 99 others); Wed, 12 May 2021 14:54:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:33470 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244029AbhELQm1 (ORCPT ); Wed, 12 May 2021 12:42:27 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7BB6761D06; Wed, 12 May 2021 16:09:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620835781; bh=ygIK7z5uOqgkpJnxwlvSZ3xDHP48hYugPkoEYMnymNw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EpifwE/qR2nfP4WUyNC6wrwle78hrHBWIT4vc4ITlmgtufla4Y6Bba8Sx340d/rST 3AVly66U4OauAvZirCqy86YybHLXsJDsaZB9vC5Ixq0NXWc2GjGQN2c16JanvrHspu d+BowR0VGEzNMZJcY9654eifuv2aOzDSjCAWLKXc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Willem de Bruijn , Paolo Abeni , "David S. Miller" , Sasha Levin Subject: [PATCH 5.12 481/677] udp: skip L4 aggregation for UDP tunnel packets Date: Wed, 12 May 2021 16:48:47 +0200 Message-Id: <20210512144853.342204678@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144837.204217980@linuxfoundation.org> References: <20210512144837.204217980@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Paolo Abeni [ Upstream commit 18f25dc399901426dff61e676ba603ff52c666f7 ] If NETIF_F_GRO_FRAGLIST or NETIF_F_GRO_UDP_FWD are enabled, and there are UDP tunnels available in the system, udp_gro_receive() could end-up doing L4 aggregation (either SKB_GSO_UDP_L4 or SKB_GSO_FRAGLIST) at the outer UDP tunnel level for packets effectively carrying and UDP tunnel header. That could cause inner protocol corruption. If e.g. the relevant packets carry a vxlan header, different vxlan ids will be ignored/ aggregated to the same GSO packet. Inner headers will be ignored, too, so that e.g. TCP over vxlan push packets will be held in the GRO engine till the next flush, etc. Just skip the SKB_GSO_UDP_L4 and SKB_GSO_FRAGLIST code path if the current packet could land in a UDP tunnel, and let udp_gro_receive() do GRO via udp_sk(sk)->gro_receive. The check implemented in this patch is broader than what is strictly needed, as the existing UDP tunnel could be e.g. configured on top of a different device: we could end-up skipping GRO at-all for some packets. Anyhow, that is a very thin corner case and covering it will add quite a bit of complexity. v1 -> v2: - hopefully clarify the commit message Fixes: 9fd1ff5d2ac7 ("udp: Support UDP fraglist GRO/GSO.") Fixes: 36707061d6ba ("udp: allow forwarding of plain (non-fraglisted) UDP GRO packets") Reviewed-by: Willem de Bruijn Signed-off-by: Paolo Abeni Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/ipv4/udp_offload.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c index c5b4b586570f..25134a3548e9 100644 --- a/net/ipv4/udp_offload.c +++ b/net/ipv4/udp_offload.c @@ -515,21 +515,24 @@ struct sk_buff *udp_gro_receive(struct list_head *head, struct sk_buff *skb, unsigned int off = skb_gro_offset(skb); int flush = 1; + /* we can do L4 aggregation only if the packet can't land in a tunnel + * otherwise we could corrupt the inner stream + */ NAPI_GRO_CB(skb)->is_flist = 0; - if (skb->dev->features & NETIF_F_GRO_FRAGLIST) - NAPI_GRO_CB(skb)->is_flist = sk ? !udp_sk(sk)->gro_enabled: 1; + if (!sk || !udp_sk(sk)->gro_receive) { + if (skb->dev->features & NETIF_F_GRO_FRAGLIST) + NAPI_GRO_CB(skb)->is_flist = sk ? !udp_sk(sk)->gro_enabled : 1; - if ((!sk && (skb->dev->features & NETIF_F_GRO_UDP_FWD)) || - (sk && udp_sk(sk)->gro_enabled) || NAPI_GRO_CB(skb)->is_flist) { - pp = call_gro_receive(udp_gro_receive_segment, head, skb); + if ((!sk && (skb->dev->features & NETIF_F_GRO_UDP_FWD)) || + (sk && udp_sk(sk)->gro_enabled) || NAPI_GRO_CB(skb)->is_flist) + pp = call_gro_receive(udp_gro_receive_segment, head, skb); return pp; } - if (!sk || NAPI_GRO_CB(skb)->encap_mark || + if (NAPI_GRO_CB(skb)->encap_mark || (uh->check && skb->ip_summed != CHECKSUM_PARTIAL && NAPI_GRO_CB(skb)->csum_cnt == 0 && - !NAPI_GRO_CB(skb)->csum_valid) || - !udp_sk(sk)->gro_receive) + !NAPI_GRO_CB(skb)->csum_valid)) goto out; /* mark that this skb passed once through the tunnel gro layer */ -- 2.30.2