Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp578949rwp; Wed, 12 Jul 2023 19:23:38 -0700 (PDT) X-Google-Smtp-Source: APBJJlEZdvSbgE8aUHxGZRkDsUGID+H086nOte7EKo6jhIMeL3iDWWtg+7TshUs0VewECb0B12Up X-Received: by 2002:a54:4f06:0:b0:3a4:3132:2a9d with SMTP id e6-20020a544f06000000b003a431322a9dmr357230oiy.19.1689215017808; Wed, 12 Jul 2023 19:23:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689215017; cv=none; d=google.com; s=arc-20160816; b=JAzZbGZP2yqToeQdwPiZ+rSydTU2lGf7ICYoleKOM46NEde6KQZcUxV0kC53BXDxzX d2xvEX+Z3BX8XnRG2mIWXlF3+jYYD+OX2vCsgcds2+nCGq1MNcf2jLpThmQNHKPOXxiU g9KXRtZxyeT/9JMs16QMPh1pEEOWMNSn3g2D67GTluoFWGBSwkjDVLUkoyvGpodlTSMr sPbLsBy8IC0YL2MBIIiHR73i7wtydQVMpy4H8CkpskRY5NgmBDQo39s3W9KTMP8ddTov sFIf38OPCyesFq2oW3+e7/51zPjG9eDcfWKXtmD5P9q78PW4cqxZ+Ou1K5Zkzclb+CH+ OzzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=oXxsxWg+t7sVZM4iHHNTkDMQqCr5a0vdCkiTjkwKBn4=; fh=yfpeW+DDkjb/sM/gNK1U0ZwSMeJETkEVBxAJmLvptgw=; b=KwnAy/r2KkH8VKIHO58mv083OY2fxyoHZ4W05HBOIYvRaf3s1VDoTpri8QdZoaaM8P bA2c81P9qgxb7dfSdP4rCX7HXwNw84My19/eDzp7w8UBuZzzoLxhPAjNv5LHIkfy0gHi q6XZ0jbypbJmO/4GlalIH6APmTXqePVH+2coEmEUWHQs3Gg/ITBwdw/G3R8ck1RSgUTI DBmAIBzutYt2VxeKEvZ9w3nXdTHr9pntsaZEpiVSbFylZ/c+l20jXIOEyyGpHzT3aUkf bjd6EPPX0U48MK9UntsC4+JOqLdgieWSnek157Qip+eZV42Kpa51fNsvMAZMWhFHzZKv GQsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DscGZJnc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bd34-20020a056a0027a200b00680a955d320si4259435pfb.56.2023.07.12.19.23.23; Wed, 12 Jul 2023 19:23:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DscGZJnc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233481AbjGMCMs (ORCPT + 99 others); Wed, 12 Jul 2023 22:12:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233469AbjGMCMq (ORCPT ); Wed, 12 Jul 2023 22:12:46 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 529471FF7 for ; Wed, 12 Jul 2023 19:11:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689214316; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oXxsxWg+t7sVZM4iHHNTkDMQqCr5a0vdCkiTjkwKBn4=; b=DscGZJnc82RKtYG1xkTFHHBHFybzU1WnEj7bSFYrt2gZN2z8Vf2ySICe/s+6NlH2mCJwDX PC0dpMtZffnlhyGfGAWRr0lJ1HUiK1HsXiI2eoy1ZgxmqZdTyG73SwQhw2UnmHiNNutE8y JOfDVeUq0WFwmScIpcRkGifHoG95LMA= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-492-Pete2mvRP0i5XS-tVSIwAw-1; Wed, 12 Jul 2023 22:11:55 -0400 X-MC-Unique: Pete2mvRP0i5XS-tVSIwAw-1 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-635984f84a9so1950986d6.0 for ; Wed, 12 Jul 2023 19:11:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689214315; x=1691806315; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oXxsxWg+t7sVZM4iHHNTkDMQqCr5a0vdCkiTjkwKBn4=; b=a+SBlNlNSuhcDS6o829hiEL3MyGa0eHvJknjRPg5aQI/mC5wbJv2d8pxtytSmu91TL i4n2syfIWCgqRh5rsuFuZMWNDLd1s4r471vtf788DCD+QKqRRS3TR/71s4Es5RKHlFBy Y4UskEtHKZ+5o1qKG34OxCzsOitTr6v6Fs0/pApw7X9tW+lrQwlyQcV2B/8oeGnMFVXn dgeAf7xNMHD1tM310LWLRxtPkcllhiRFK8RLXs7b9nwgmyS87ZHPD4gt5ilMvfcbEC40 pjmzoCNWNEx5moVZ/GP4GZgeuk6ioDTBz7w0uM4WZsp9ZtIQEXL9hcSoULNc730kILvV 3GNw== X-Gm-Message-State: ABy/qLZXwamICv/Nvt0w75//Lbik/swpJBEek1wmElPXK6Y3cSJMsDrq xsLSImAGDUFm5TTODZgHamlL4giqch+GP9ZlR5msdRsgOysILnD6mjUPKKXstHjsN4+i0XEo7R5 n1lTAWSU7MtNVJgpWunHcAC5j/biPJiKDpsjL4fv/ X-Received: by 2002:a0c:cb0c:0:b0:635:e6e0:6814 with SMTP id o12-20020a0ccb0c000000b00635e6e06814mr208271qvk.49.1689214315003; Wed, 12 Jul 2023 19:11:55 -0700 (PDT) X-Received: by 2002:a0c:cb0c:0:b0:635:e6e0:6814 with SMTP id o12-20020a0ccb0c000000b00635e6e06814mr208257qvk.49.1689214314752; Wed, 12 Jul 2023 19:11:54 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Jason Wang Date: Thu, 13 Jul 2023 10:11:43 +0800 Message-ID: Subject: Re: [PATCH net] gso: fix GSO_DODGY bit handling for related protocols To: Willem de Bruijn Cc: Yan Zhai , "open list:NETWORKING [TCP]" , kernel-team@cloudflare.com, Eric Dumazet , "David S. Miller" , David Ahern , Jakub Kicinski , Paolo Abeni , Marcelo Ricardo Leitner , Xin Long , Herbert Xu , Andrew Melnychenko , open list , "open list:SCTP PROTOCOL" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 13, 2023 at 10:02=E2=80=AFAM Willem de Bruijn wrote: > > On Wed, Jul 12, 2023 at 9:55=E2=80=AFPM Yan Zhai wro= te: > > > > SKB_GSO_DODGY bit indicates a GSO packet comes from an untrusted source= . > > The canonical way is to recompute the gso_segs to avoid device driver > > issues. Afterwards, the DODGY bit can be removed to avoid re-check at t= he > > egress of later devices, e.g. packets can egress to a vlan device backe= d > > by a real NIC. > > > > Commit 1fd54773c267 ("udp: allow header check for dodgy GSO_UDP_L4 > > packets.") checks DODGY bit for UDP, but for packets that can be fed > > directly to the device after gso_segs reset, it actually falls through > > to fragmentation [1]. > > > > Commit 90017accff61 ("sctp: Add GSO support") and commit 3820c3f3e417 > > ("[TCP]: Reset gso_segs if packet is dodgy") both didn't remove the DOD= GY > > bit after recomputing gso_segs. > > > > This change fixes the GSO_UDP_L4 handling case, and remove the DODGY bi= t > > at other places. > > These two things should not be conflated. > > Only the USO fix is strictly needed to fix the reported issue. > > > Fixes: 90017accff61 ("sctp: Add GSO support") > > Fixes: 3820c3f3e417 ("[TCP]: Reset gso_segs if packet is dodgy") > > Fixes: 1fd54773c267 ("udp: allow header check for dodgy GSO_UDP_L4 pack= ets.") > > Link: https://lore.kernel.org/all/CAJPywTKDdjtwkLVUW6LRA2FU912qcDmQOQGt2W= aDo28KzYDg+A@mail.gmail.com/ > > > Signed-off-by: Yan Zhai > > > > --- > > [1]: > > https://lore.kernel.org/all/CAJPywTKDdjtwkLVUW6LRA2FU912qcDmQOQGt2WaDo2= 8KzYDg+A@mail.gmail.com/ > > > > --- > > net/ipv4/tcp_offload.c | 1 + > > net/ipv4/udp_offload.c | 19 +++++++++++++++---- > > net/ipv6/udp_offload.c | 19 +++++++++++++++---- > > net/sctp/offload.c | 2 ++ > > 4 files changed, 33 insertions(+), 8 deletions(-) > > > > diff --git a/net/ipv4/tcp_offload.c b/net/ipv4/tcp_offload.c > > index 8311c38267b5..f9b93708c22e 100644 > > --- a/net/ipv4/tcp_offload.c > > +++ b/net/ipv4/tcp_offload.c > > @@ -87,6 +87,7 @@ struct sk_buff *tcp_gso_segment(struct sk_buff *skb, > > /* Packet is from an untrusted source, reset gso_segs. = */ > > > > skb_shinfo(skb)->gso_segs =3D DIV_ROUND_UP(skb->len, ms= s); > > + skb_shinfo(skb)->gso_type &=3D ~SKB_GSO_DODGY; > > > > segs =3D NULL; > > goto out; > > diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c > > index 75aa4de5b731..bd29cf19bb6b 100644 > > --- a/net/ipv4/udp_offload.c > > +++ b/net/ipv4/udp_offload.c > > @@ -388,11 +388,22 @@ static struct sk_buff *udp4_ufo_fragment(struct s= k_buff *skb, > > if (!pskb_may_pull(skb, sizeof(struct udphdr))) > > goto out; > > > > - if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4 && > > - !skb_gso_ok(skb, features | NETIF_F_GSO_ROBUST)) > > - return __udp_gso_segment(skb, features, false); > > - > > mss =3D skb_shinfo(skb)->gso_size; > > Why move the block below this line? > > > + > > + if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4) { > > + if (skb_gso_ok(skb, features | NETIF_F_GSO_ROBUST)) { > > + /* Packet is from an untrusted source, reset ac= tual gso_segs */ > > + skb_shinfo(skb)->gso_segs =3D DIV_ROUND_UP(skb-= >len - sizeof(*uh), > > + mss); > > + skb_shinfo(skb)->gso_type &=3D ~SKB_GSO_DODGY; > > + > > + segs =3D NULL; > > + goto out; > > + } else { > > + return __udp_gso_segment(skb, features, false); > > + } > > + } > > + > > The validation should take place inside __udp_gso_segment. > > Revert the previous patch to always enter that function for USO packets: > > if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4) > return __udp_gso_segment(skb, features, false); > > And in that function decide to return NULL after validation. +1 Thanks > > > > if (unlikely(skb->len <=3D mss)) > > goto out; > > > > diff --git a/net/ipv6/udp_offload.c b/net/ipv6/udp_offload.c > > index ad3b8726873e..6857d9f7bd06 100644 > > --- a/net/ipv6/udp_offload.c > > +++ b/net/ipv6/udp_offload.c > > @@ -43,11 +43,22 @@ static struct sk_buff *udp6_ufo_fragment(struct sk_= buff *skb, > > if (!pskb_may_pull(skb, sizeof(struct udphdr))) > > goto out; > > > > - if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4 && > > - !skb_gso_ok(skb, features | NETIF_F_GSO_ROBUST)) > > - return __udp_gso_segment(skb, features, true); > > - > > mss =3D skb_shinfo(skb)->gso_size; > > + > > + if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4) { > > + if (skb_gso_ok(skb, features | NETIF_F_GSO_ROBU= ST)) { > > + /* Packet is from an untrusted source, = reset actual gso_segs */ > > + skb_shinfo(skb)->gso_segs =3D DIV_ROUND= _UP(skb->len - sizeof(*uh), > > + = mss); > > + skb_shinfo(skb)->gso_type &=3D ~SKB_GSO= _DODGY; > > + > > + segs =3D NULL; > > + goto out; > > + } else { > > + return __udp_gso_segment(skb, features,= true); > > + } > > + } > > + > > if (unlikely(skb->len <=3D mss)) > > goto out; > > > > diff --git a/net/sctp/offload.c b/net/sctp/offload.c > > index 502095173d88..3d2b44db0d42 100644 > > --- a/net/sctp/offload.c > > +++ b/net/sctp/offload.c > > @@ -65,6 +65,8 @@ static struct sk_buff *sctp_gso_segment(struct sk_buf= f *skb, > > skb_walk_frags(skb, frag_iter) > > pinfo->gso_segs++; > > > > + pinfo->gso_type &=3D ~SKB_GSO_DODGY; > > + > > segs =3D NULL; > > goto out; > > } > > -- > > 2.30.2 > > >