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 3A9AEA00C2 for ; Thu, 3 Nov 2022 10:30:50 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 35EF042685; Thu, 3 Nov 2022 10:30:50 +0100 (CET) Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) by mails.dpdk.org (Postfix) with ESMTP id D3E0440693 for ; Thu, 3 Nov 2022 10:30:48 +0100 (CET) Received: by mail-wm1-f45.google.com with SMTP id t4so684902wmj.5 for ; Thu, 03 Nov 2022 02:30:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HtzM5bo5FC63PsMuEpY9UaDN9dfa2+CvjqHaimvf6Kg=; b=BSHmJd3LJsvsDXGfgDxD6komhpjn60OFT6xkR2ToYEjAzbXu8ifGq/BrMGq9/2s6F/ E8yAdpUCpAE0H2kwGEj8zwj4pxgzsj4EpmYTG7c3S3/2jbTALeF8ykHVERSxznXuEUB9 6zBa+eVUfSX+sHpJgAIcxgJ32NKLnw0dT/UWrn0GYLGOYXatTVnH0EFIwnEmh78hKY1v 6rlrPXeoUd3qD0G5Vlx0TqbwGcH5SovGuiKZ5sGyP0zd8hb68V/JrIiZDI+G4Fqv8KjV ovUoWY9WJDiQFg2wnEyXEQidC1wZaEYvs8+QDB9v+brSVuwIg39jo5VYPmpoBqdZyvLi KiGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HtzM5bo5FC63PsMuEpY9UaDN9dfa2+CvjqHaimvf6Kg=; b=aO4tEXAuQfJgr/3WOfCxh9xtvJdlks77dbgh4NC9pAAb/3cHftpFctsuNIlTQNFuqk hbWks8hpOS6wonhqUgMZSF6Ce8V+ydHcAKL2U/pS6uzisfaP/K7ps/TyYs/N2sMuo9Tx vJwCkrxxNeu1QFfXxNHpJYM6h+L0xpemyf69GWBJOwDW7lt5J+S6yjrTzP6gp0BWq153 YOS7AAbioSPRxMUnU25cMCqVcSVuXqO6h8gv4Bu16d0QYn3pgAB3WGoq65i/z1fOuVv+ 17y1qFuexfPRvKXQMYiJZdNSvRVcsXfKLONEMXhrVA7dNWIdiaFLS4SL/Lsc5bFhUJ9e KzDw== X-Gm-Message-State: ACrzQf1KFR9xaj7Fhv4Kb1aceRMMyH5nLruggwMv8rCTOcvlg1O2EJej DZVknjACEWmP40wT813f3niySgyz+rhaXc+Z X-Google-Smtp-Source: AMsMyM5OfmFKh3GxEFZsJ7xMqBQcz404sYC/QGBKypYZ/XWdgmuDvVIomUgpPC5T/iVj91iU3oBT+Q== X-Received: by 2002:a05:600c:3b0d:b0:3cf:82d2:8c61 with SMTP id m13-20020a05600c3b0d00b003cf82d28c61mr7120586wms.0.1667467848568; Thu, 03 Nov 2022 02:30:48 -0700 (PDT) Received: from localhost ([2a01:4b00:d307:1000:f1d3:eb5e:11f4:a7d9]) by smtp.gmail.com with ESMTPSA id f22-20020a05600c44d600b003cf6e1df4a8sm673939wmo.15.2022.11.03.02.30.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Nov 2022 02:30:48 -0700 (PDT) From: luca.boccassi@gmail.com To: Kevin Liu Cc: Qi Zhang , dpdk stable Subject: patch 'net/iavf: check illegal packet sizes' has been queued to stable release 20.11.7 Date: Thu, 3 Nov 2022 09:27:08 +0000 Message-Id: <20221103092758.1099402-50-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221103092758.1099402-1-luca.boccassi@gmail.com> References: <20221103092758.1099402-1-luca.boccassi@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 Hi, FYI, your patch has been queued to stable release 20.11.7 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 11/05/22. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/kevintraynor/dpdk-stable This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable/commit/4f523b99acacdee90cdc42b3e85ec9e48e975388 Thanks. Luca Boccassi --- >From 4f523b99acacdee90cdc42b3e85ec9e48e975388 Mon Sep 17 00:00:00 2001 From: Kevin Liu Date: Tue, 27 Sep 2022 07:15:21 +0000 Subject: [PATCH] net/iavf: check illegal packet sizes [ upstream commit 19ee91c6bd9a196b17394d69b18576a7ff8e2489 ] If the length of data_len in mbuf is less than 17 or greater than the maximum frame size, it is illegal. These illegal packets will lead to Tx/Rx hang and can't recover automatically. This patch check those illegal packets and protect Tx/Rx from hanging. Fixes: a2b29a7733ef ("net/avf: enable basic Rx Tx") Signed-off-by: Kevin Liu Acked-by: Qi Zhang --- drivers/net/iavf/iavf_rxtx.c | 13 ++++++++++++- drivers/net/iavf/iavf_rxtx.h | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c index f6049d8694..0053a36de2 100644 --- a/drivers/net/iavf/iavf_rxtx.c +++ b/drivers/net/iavf/iavf_rxtx.c @@ -2329,12 +2329,15 @@ end_of_tx: /* TX prep functions */ uint16_t -iavf_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts, +iavf_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) { int i, ret; uint64_t ol_flags; struct rte_mbuf *m; + struct iavf_tx_queue *txq = tx_queue; + struct rte_eth_dev *dev = &rte_eth_devices[txq->port_id]; + uint16_t max_frame_size = dev->data->mtu + IAVF_ETH_OVERHEAD; for (i = 0; i < nb_pkts; i++) { m = tx_pkts[i]; @@ -2358,6 +2361,14 @@ iavf_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts, return i; } + /* check the data_len in mbuf */ + if (m->data_len < IAVF_TX_MIN_PKT_LEN || + m->data_len > max_frame_size) { + rte_errno = EINVAL; + PMD_DRV_LOG(ERR, "INVALID mbuf: bad data_len=[%hu]", m->data_len); + return i; + } + #ifdef RTE_LIBRTE_ETHDEV_DEBUG ret = rte_validate_tx_offload(m); if (ret != 0) { diff --git a/drivers/net/iavf/iavf_rxtx.h b/drivers/net/iavf/iavf_rxtx.h index 557a7e46a7..047743de4f 100644 --- a/drivers/net/iavf/iavf_rxtx.h +++ b/drivers/net/iavf/iavf_rxtx.h @@ -39,6 +39,8 @@ #define IAVF_TSO_MAX_SEG UINT8_MAX #define IAVF_TX_MAX_MTU_SEG 8 +#define IAVF_TX_MIN_PKT_LEN 17 + #define IAVF_TX_CKSUM_OFFLOAD_MASK ( \ PKT_TX_IP_CKSUM | \ PKT_TX_L4_MASK | \ -- 2.34.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2022-11-03 09:27:28.463235768 +0000 +++ 0050-net-iavf-check-illegal-packet-sizes.patch 2022-11-03 09:27:25.449423912 +0000 @@ -1 +1 @@ -From 19ee91c6bd9a196b17394d69b18576a7ff8e2489 Mon Sep 17 00:00:00 2001 +From 4f523b99acacdee90cdc42b3e85ec9e48e975388 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 19ee91c6bd9a196b17394d69b18576a7ff8e2489 ] + @@ -16 +17,0 @@ -Cc: stable@dpdk.org @@ -21,3 +22,3 @@ - drivers/net/iavf/iavf_rxtx.c | 9 +++++++++ - drivers/net/iavf/iavf_rxtx.h | 2 ++ - 2 files changed, 11 insertions(+) + drivers/net/iavf/iavf_rxtx.c | 13 ++++++++++++- + drivers/net/iavf/iavf_rxtx.h | 2 ++ + 2 files changed, 14 insertions(+), 1 deletion(-) @@ -26 +27 @@ -index fc5d9e38cc..89a1d141ba 100644 +index f6049d8694..0053a36de2 100644 @@ -29 +30,10 @@ -@@ -2916,6 +2916,7 @@ iavf_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts, +@@ -2329,12 +2329,15 @@ end_of_tx: + + /* TX prep functions */ + uint16_t +-iavf_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts, ++iavf_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, + uint16_t nb_pkts) + { + int i, ret; + uint64_t ol_flags; @@ -31,2 +41,2 @@ - struct iavf_tx_queue *txq = tx_queue; - struct rte_eth_dev *dev = &rte_eth_devices[txq->port_id]; ++ struct iavf_tx_queue *txq = tx_queue; ++ struct rte_eth_dev *dev = &rte_eth_devices[txq->port_id]; @@ -34,2 +43,0 @@ - struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private); - struct iavf_adapter *adapter = IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private); @@ -37 +45,3 @@ -@@ -2944,6 +2945,14 @@ iavf_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts, + for (i = 0; i < nb_pkts; i++) { + m = tx_pkts[i]; +@@ -2358,6 +2361,14 @@ iavf_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts, @@ -49 +59 @@ - #ifdef RTE_ETHDEV_DEBUG_TX + #ifdef RTE_LIBRTE_ETHDEV_DEBUG @@ -53 +63 @@ -index 66e832713c..3c89303980 100644 +index 557a7e46a7..047743de4f 100644 @@ -56 +66 @@ -@@ -55,6 +55,8 @@ +@@ -39,6 +39,8 @@ @@ -63,2 +73,2 @@ - RTE_MBUF_F_TX_IP_CKSUM | \ - RTE_MBUF_F_TX_L4_MASK | \ + PKT_TX_IP_CKSUM | \ + PKT_TX_L4_MASK | \