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 454E5A00BE for ; Fri, 22 Apr 2022 12:28:26 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3A9A0410F5; Fri, 22 Apr 2022 12:28:26 +0200 (CEST) Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) by mails.dpdk.org (Postfix) with ESMTP id 5AF6940042; Fri, 22 Apr 2022 12:28:24 +0200 (CEST) Received: by mail-pf1-f175.google.com with SMTP id j17so7596467pfi.9; Fri, 22 Apr 2022 03:28:24 -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:mime-version :content-transfer-encoding; bh=Wul3Kwf7QAYBoN8/nFbF6Tj90hQ99OQ2BYkkjugT7vo=; b=RnSG+Z7pGKH3NrNyaubk7gH3YqD6H94RTbD/Ie4UxQ9/jy8w+P2vPgWczOOoTtzLQ0 Ch3/K7Uuc/YCXHtBm1LqEo/emuz5PZK/7KcqbgtsfzxrN1IN5h/lxdXOhuFmC21tv8Cq Z36ot7JWaXUx5dK5bXlSFF8gLqMpjbf4+QCiJ0OYQV9t3DYeNp97kY/TTnR9QaGNjFZn w7HvniCFREvP6iSmHZ3IFj0QSypU06tQUnivuMqJf/8lg6IsUImlBpTrpUH5NsNRpYmx whlFriKg6btyX+upzr2s2s1Qinnypk+p7d/HwmHkcMMakoLb0pnSkwqjnn4elR85BWU5 l+WA== 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:mime-version :content-transfer-encoding; bh=Wul3Kwf7QAYBoN8/nFbF6Tj90hQ99OQ2BYkkjugT7vo=; b=RngG1vf1OaAiSJITfXhCyvfnu+cmYpjND3N0vnkrX6e4dXO8EeRkJrLcjWxJFuBh2i cGsrBs7YRfas7il1avxhClngrlql5soeFQXq6j1oFaasnhx/AK7Ivdg9Wwb67A8fr+To lT5Hj+MdkiHynj6ZYhA9L0tp68DH68ER62H5P25vlXMIpO4wO32aILgMRFlp+LxlIQ+x CJV4Z/NJeagKqiX+a5YOXv6gIc6YlIqwqF06U3L2arRpSMAM2Ht/CdlcYh+3n5KStG8o Aa5UKlQCErC6QGWhMrvuFuYdI+ZP183pGxFSjrVwDeA3LsebFzAbL2guDTplb3jRkhLI n2fg== X-Gm-Message-State: AOAM532kexxQGcBJ+3EXL00qsvYmOzo/UPVH/sibMzsH2Xzs0yitjSyN ovusUsEeWubAOeLVy20Zu8E= X-Google-Smtp-Source: ABdhPJzZHusPm6P38nfRVyZOrX45hSWNi8olv76v3poE6R8iOqkGzBlp8TE7HN2qg3wCVp8WBbcXvQ== X-Received: by 2002:a63:6401:0:b0:3aa:5639:1884 with SMTP id y1-20020a636401000000b003aa56391884mr3264110pgb.71.1650623303477; Fri, 22 Apr 2022 03:28:23 -0700 (PDT) Received: from kparameshwa-a02.vmware.com.com ([49.206.14.100]) by smtp.gmail.com with ESMTPSA id d21-20020a056a0010d500b004fd9ee64134sm2109201pfu.74.2022.04.22.03.28.21 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 22 Apr 2022 03:28:23 -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 15:58:15 +0530 Message-Id: <20220422102815.82074-1-kumaraparmesh92@gmail.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) 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