From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D6D3DA00BE for ; Fri, 22 Apr 2022 12:32:40 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CEFD2410F5; Fri, 22 Apr 2022 12:32:40 +0200 (CEST) Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) by mails.dpdk.org (Postfix) with ESMTP id C992640042; Fri, 22 Apr 2022 12:32:38 +0200 (CEST) Received: by mail-pg1-f178.google.com with SMTP id h5so7011422pgc.7; Fri, 22 Apr 2022 03:32:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Wul3Kwf7QAYBoN8/nFbF6Tj90hQ99OQ2BYkkjugT7vo=; b=PMnq3IgRdhmu2lHaHtzAh0Uu/XSAVaOBHUDJDTSPrr/2pVeoE5NLfXPM3DCSBl+IfZ tt0N2XDCt/gWK8nUR2oUY0BRUl6TLdjRbO1AinEXuh2n2K9F/1Ibs1FX4hWbzA3Jf2np j8S7vSDmuTWB0no014t13/Fiwd4yWTuq1sB+ZQiMR0uAI92rdOyjF735DAOCc0LV0q4b fFCzk06Ehc+zDuMzgRMV0rBAlMxHNl12bWAhLkLoJMyL9evEB12e77raVqU9HxYV5ppQ psyCZbKmD6zyzyAnaolxswqy42Z8b4vjcHTmsewau8oRl81yo2fNOWwe200/kqECQDeK ApCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Wul3Kwf7QAYBoN8/nFbF6Tj90hQ99OQ2BYkkjugT7vo=; b=iKilehqaoDCGr+gGHkBYxcxO6OjoGsY7IQTOYfB6zIEKidHb8C3COuw4JifR4zQqao rwrVBVAkJ0mDO+vMRwGi83znIAuBuVNozMoJ8ndyRWhMn99y5gi5/ErKbEFkxc9q5Gk/ xNz/mfGYAQL5KsvYy/8AFz7ooau8gwU+NYkI8uY0qaLvUpKSsLFmn70GSRUvfWf7ognV EW8xqwkUTGtdtUtWM66lRhJcWUrkoQXjd9kdXKE/OgzaL6r/XltnzWUm35cxHGuon5i2 Aqb42ovanptEnsrqlz3g7ykd4P9/JOZkCY+uN3nlMTCcMl4IKegX0GamVcDzhl979QYT 1RFw== X-Gm-Message-State: AOAM531dUTNMVqXiWPcqeAiQE4PBmhrBuyGfwtG97A2MBJ5u4nvn4aS/ jOz9y0Qu47zAVEpcp7IRA28= X-Google-Smtp-Source: ABdhPJwvmI09iajhJpg+RSvXEakdzKCOV/47+320AAJOLPs3cvoGyPfxOcjDDrUlrEP/hxFWKpStlA== X-Received: by 2002:a05:6a00:10cc:b0:505:ada6:e03e with SMTP id d12-20020a056a0010cc00b00505ada6e03emr4219495pfu.45.1650623557949; Fri, 22 Apr 2022 03:32:37 -0700 (PDT) Received: from kparameshwa-a02.vmware.com.com ([49.206.14.100]) by smtp.gmail.com with ESMTPSA id bw22-20020a056a00409600b0050a8e795672sm2038563pfb.29.2022.04.22.03.32.35 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 22 Apr 2022 03:32:37 -0700 (PDT) From: Kumara Parameshwaran X-Google-Original-From: Kumara Parameshwaran To: jiayu.hu@intel.com Cc: dev@dpdk.org, Kumara Parameshwaran , stable@dpdk.org, Kumara Parameshwaran Subject: [PATCH v2] gro: bug fix in identifying 0 length tcp packets Date: Fri, 22 Apr 2022 16:02:31 +0530 Message-Id: <20220422103231.82212-1-kumaraparmesh92@gmail.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) In-Reply-To: <20220403115031.59632-1-kumaraparamesh92@gmail.com> References: <20220403115031.59632-1-kumaraparamesh92@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org From: Kumara Parameshwaran As the minimum Ethernet frame size is 64 bytes, a 0 length tcp payload without tcp options would be 54 bytes and hence there would be padding. So it would be incorrect to use the packet length to determine the tcp data length. Fixes: 1e4cf4d6d4fb ("gro: cleanup") Cc: stable@dpdk.org Signed-off-by: Kumara Parameshwaran --- v1: Do not use packet length to determine the tcp data length as the packet length could have padded bytes. This would lead to addition of 0 length tcp packets into the GRO layer when there ethernet fram is padded. v2: Since using ip packet length to determine the tcp data length, validate the ip packet length lib/gro/gro_tcp4.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/gro/gro_tcp4.c b/lib/gro/gro_tcp4.c index 7498c66..30f5922 100644 --- a/lib/gro/gro_tcp4.c +++ b/lib/gro/gro_tcp4.c @@ -198,7 +198,8 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt, struct rte_tcp_hdr *tcp_hdr; uint32_t sent_seq; int32_t tcp_dl; - uint16_t ip_id, hdr_len, frag_off; + uint16_t ip_id, frag_off; + uint16_t ip_len; uint8_t is_atomic; struct tcp4_flow_key key; @@ -217,7 +218,6 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt, eth_hdr = rte_pktmbuf_mtod(pkt, struct rte_ether_hdr *); ipv4_hdr = (struct rte_ipv4_hdr *)((char *)eth_hdr + pkt->l2_len); tcp_hdr = (struct rte_tcp_hdr *)((char *)ipv4_hdr + pkt->l3_len); - hdr_len = pkt->l2_len + pkt->l3_len + pkt->l4_len; /* * Don't process the packet which has FIN, SYN, RST, PSH, URG, ECE @@ -229,8 +229,9 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt, * Don't process the packet whose payload length is less than or * equal to 0. */ - tcp_dl = pkt->pkt_len - hdr_len; - if (tcp_dl <= 0) + ip_len = rte_be_to_cpu_16(ipv4_hdr->total_length); + tcp_dl = ip_len - (pkt->l3_len + pkt->l4_len); + if (tcp_dl <= 0 || ip_len > pkt->pkt_len) return -1; /* -- 2.7.4