From patchwork Tue Aug 27 20:28:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magali Lemes X-Patchwork-Id: 1977466 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WtfKW3K1Vz1yfn for ; Wed, 28 Aug 2024 06:29:35 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1sj2og-0007Kh-AY; Tue, 27 Aug 2024 20:29:26 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1sj2of-0007IA-2U for kernel-team@lists.ubuntu.com; Tue, 27 Aug 2024 20:29:25 +0000 Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id D7EE53F183 for ; Tue, 27 Aug 2024 20:29:24 +0000 (UTC) Received: by mail-pf1-f198.google.com with SMTP id d2e1a72fcca58-71454420f65so3381934b3a.1 for ; Tue, 27 Aug 2024 13:29:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724790562; x=1725395362; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8/YCzNLbgWmrSeo7XtL1wI5UE7Dxmo0IWDPSanaW1tI=; b=FvRL4rLDct1+eMjCvny3/N1g/7mvxU8pe8INMAoeVaoI/zjHJNZb4z9tAEkLO1EfNi KaI93V+7IH/5S8EUXeTL9E0DaJUNKCuQFQ4ohwIV2B/evvSOsQDksGPMpT65aFSPljJS VSvVQa/tJqRlSkJDOcMBI5DodmKs/oRvVKG1ApLeCrFIjeK0dDIPPcRGmrxKGFuG19mA ooXzdjdFFDy7Th9vlTAx06W/VAp/EVs9ZQ+FA7Gk0rsh5vuceLI7Y3lRUu/0d0v2eqzM QXfou1v4yvCB8+0h/S74YSqTi6xpZw+8PP+e/SPKfqbWsyMRlpii8ti/kUarHDo24arq O5AA== X-Gm-Message-State: AOJu0Yz4X497FsINL9JiXSGHnoRjG84pbAWeCRIKYNS7DlsBG9BC4h2f Jh5+bvw73vKFUVfJW51B1u0aoNGciF2P56akI3zoGa1C6S2TyfkdhquIuVcC7akKhkkdiY1YVE1 fugZFMMLGnzHYXEZk9F0VMxMWDCFXbddiumEPBz5AiVi9kN62sG5zDe/xE3LWH3XU1Ezr/4rq4j lEuCI6s004UQ== X-Received: by 2002:a05:6a00:66d1:b0:714:186a:ae0b with SMTP id d2e1a72fcca58-71445e77f21mr13960338b3a.24.1724790562565; Tue, 27 Aug 2024 13:29:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEcfvDdcgqZRNtlJWifGZx2UR+NyMBiVtQ1pPC7cSjydv46VcowUzJny8p/d19KsgOB+TuOCQ== X-Received: by 2002:a05:6a00:66d1:b0:714:186a:ae0b with SMTP id d2e1a72fcca58-71445e77f21mr13960323b3a.24.1724790562106; Tue, 27 Aug 2024 13:29:22 -0700 (PDT) Received: from localhost.localdomain ([2804:14c:14a:8141:7d63:49a5:3ea2:be5d]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71434316102sm9253698b3a.175.2024.08.27.13.29.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2024 13:29:20 -0700 (PDT) From: Magali Lemes To: kernel-team@lists.ubuntu.com Subject: [SRU][jammy:linux-gke/linux-gkeop][PATCH 1/2] gve: ignore nonrelevant GSO type bits when processing TSO headers Date: Tue, 27 Aug 2024 17:28:52 -0300 Message-Id: <20240827202853.94286-2-magali.lemes@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240827202853.94286-1-magali.lemes@canonical.com> References: <20240827202853.94286-1-magali.lemes@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Joshua Washington BugLink: https://bugs.launchpad.net/bugs/2077571 TSO currently fails when the skb's gso_type field has more than one bit set. TSO packets can be passed from userspace using PF_PACKET, TUNTAP and a few others, using virtio_net_hdr (e.g., PACKET_VNET_HDR). This includes virtualization, such as QEMU, a real use-case. The gso_type and gso_size fields as passed from userspace in virtio_net_hdr are not trusted blindly by the kernel. It adds gso_type |= SKB_GSO_DODGY to force the packet to enter the software GSO stack for verification. This issue might similarly come up when the CWR bit is set in the TCP header for congestion control, causing the SKB_GSO_TCP_ECN gso_type bit to be set. Fixes: a57e5de476be ("gve: DQO: Add TX path") Signed-off-by: Joshua Washington Reviewed-by: Praveen Kaligineedi Reviewed-by: Harshitha Ramamurthy Reviewed-by: Willem de Bruijn Suggested-by: Eric Dumazet Acked-by: Andrei Vagin v2 - Remove unnecessary comments, remove line break between fixes tag and signoffs. v3 - Add back unrelated empty line removal. Link: https://lore.kernel.org/r/20240610225729.2985343-1-joshwash@google.com Signed-off-by: Jakub Kicinski (backported from commit 1b9f756344416e02b41439bf2324b26aa25e141c) [magalilemes: missing upstream commit 504148fedb85 ("net: add skb_[inner_]tcp_all_headers helpers") causes a context conflict, which is safe to ignore. Accept incoming changes and replace the call to the skb_tcp_all_headers() helper with its implementation.] Signed-off-by: Magali Lemes --- drivers/net/ethernet/google/gve/gve_tx_dqo.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/drivers/net/ethernet/google/gve/gve_tx_dqo.c b/drivers/net/ethernet/google/gve/gve_tx_dqo.c index 94e3b74a10f22..3120a82672e40 100644 --- a/drivers/net/ethernet/google/gve/gve_tx_dqo.c +++ b/drivers/net/ethernet/google/gve/gve_tx_dqo.c @@ -370,28 +370,18 @@ static int gve_prep_tso(struct sk_buff *skb) if (unlikely(skb_shinfo(skb)->gso_size < GVE_TX_MIN_TSO_MSS_DQO)) return -1; + if (!(skb_shinfo(skb)->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6))) + return -EINVAL; + /* Needed because we will modify header. */ err = skb_cow_head(skb, 0); if (err < 0) return err; tcp = tcp_hdr(skb); - - /* Remove payload length from checksum. */ paylen = skb->len - skb_transport_offset(skb); - - switch (skb_shinfo(skb)->gso_type) { - case SKB_GSO_TCPV4: - case SKB_GSO_TCPV6: - csum_replace_by_diff(&tcp->check, - (__force __wsum)htonl(paylen)); - - /* Compute length of segmentation header. */ - header_len = skb_transport_offset(skb) + tcp_hdrlen(skb); - break; - default: - return -EINVAL; - } + csum_replace_by_diff(&tcp->check, (__force __wsum)htonl(paylen)); + header_len = skb_transport_offset(skb) + tcp_hdrlen(skb); if (unlikely(header_len > GVE_TX_MAX_HDR_SIZE_DQO)) return -EINVAL;