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 68DE6A00C2 for ; Thu, 3 Nov 2022 10:31:01 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 635F940694; Thu, 3 Nov 2022 10:31:01 +0100 (CET) Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) by mails.dpdk.org (Postfix) with ESMTP id 1C93E40693 for ; Thu, 3 Nov 2022 10:31:00 +0100 (CET) Received: by mail-wr1-f48.google.com with SMTP id j15so1741480wrq.3 for ; Thu, 03 Nov 2022 02:31:00 -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=G6tqQSfBPugGOGp9B6Fz/P97a9Vp6b3XUYs96nrOFX4=; b=AF1QwDvxfkCbd6NXwDyETdgx7Qze5UkbMlNEt1uTnotwDs82R8m/5s9Z8Bhq0pZ94E iMWycujzy6ZK/sfdtpsmJDlfkqtwOiN9zO0CBUQtdXCU3gjlETxpXtRE7ofFBrUPENoc irfMRclls/J5VzRxQRND5PPlxOtYZH0/MXPl1kgKrbnmAFtV/NUoYvzy3EYfQlQBYl84 ZAq1lbnweUe2Z89D8X2Ghcb1pMRd5UWXkZDqGuVMpQjpM+SNG7fXM33L0sq489rxxA2A 3a7KkseefT/gKzEfbW+zeZlddCZw1phRSRQQcuzXfEhBq4aoTAEMJ9eNQ95isvq1Hitm q6Vg== 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=G6tqQSfBPugGOGp9B6Fz/P97a9Vp6b3XUYs96nrOFX4=; b=bbVi5NOG1V2OnAPgcyw1bYb+gQthnUvx15MuSNk+GFh5nSW40wWLwOr8FspnvxhXI6 qUQigQ5bWcjeYpC5EjZoCcZX05d3hae9vAOZgoj33gKHPkb9tDcYxHDWKjrNP/W5umbG Hx/gjx6a4MWWRxHn4U5R4V3GimoXW12+rsnmUVIQ5EgbTKQOEojnQOxDG6l94Ew0To/r 69+eQpKgV1HMVxTknknMyWiR9DrF/939blOC7E5A3cb1XV2+RvhsT23t4tg+nqyC9P61 1RxN5zbhrqj9sYkRH8VGpZl592DJchitrRRG3Q7VMg1hkfXccO4Py71wtq0bmv2pRWdg 8Uaw== X-Gm-Message-State: ACrzQf3ovhsbSR3oeG9W0XN2sfCKn0/t7DmWe+FGC5RMeyJDgK53ajKU lDbQtExSGNd8uY4lssJppyE= X-Google-Smtp-Source: AMsMyM68dvlZH2BJOC/OQiHcsrGIv0OWqBWqjq6XUXlksMhAGRmsOCphDCXUtogRYyZFI3Gy/PvbQw== X-Received: by 2002:a5d:6f1e:0:b0:236:63f8:d03d with SMTP id ay30-20020a5d6f1e000000b0023663f8d03dmr18146517wrb.646.1667467859758; Thu, 03 Nov 2022 02:30:59 -0700 (PDT) Received: from localhost ([2a01:4b00:d307:1000:f1d3:eb5e:11f4:a7d9]) by smtp.gmail.com with ESMTPSA id c3-20020adffb43000000b0022e344a63c7sm304623wrs.92.2022.11.03.02.30.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Nov 2022 02:30:59 -0700 (PDT) From: luca.boccassi@gmail.com To: Kevin Liu Cc: Qi Zhang , dpdk stable Subject: patch 'net/ice: check illegal packet sizes' has been queued to stable release 20.11.7 Date: Thu, 3 Nov 2022 09:27:09 +0000 Message-Id: <20221103092758.1099402-51-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/5d9ff0ecf09710cd71e42eca104aedb39d0a521d Thanks. Luca Boccassi --- >From 5d9ff0ecf09710cd71e42eca104aedb39d0a521d Mon Sep 17 00:00:00 2001 From: Kevin Liu Date: Tue, 27 Sep 2022 07:15:22 +0000 Subject: [PATCH] net/ice: check illegal packet sizes [ upstream commit ccf33dccf7aaf208ef67ed7b8ef45d05bce5e3a5 ] 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: 17c7d0f9d6a4 ("net/ice: support basic Rx/Tx") Signed-off-by: Kevin Liu Acked-by: Qi Zhang --- drivers/net/ice/ice_rxtx.c | 11 +++++++++++ drivers/net/ice/ice_rxtx.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c index 5f94b4174d..fe1f3eea2d 100644 --- a/drivers/net/ice/ice_rxtx.c +++ b/drivers/net/ice/ice_rxtx.c @@ -3209,6 +3209,9 @@ ice_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts, int i, ret; uint64_t ol_flags; struct rte_mbuf *m; + struct ice_tx_queue *txq = tx_queue; + struct rte_eth_dev *dev = &rte_eth_devices[txq->port_id]; + uint16_t max_frame_size = dev->data->mtu + ICE_ETH_OVERHEAD; for (i = 0; i < nb_pkts; i++) { m = tx_pkts[i]; @@ -3225,6 +3228,14 @@ ice_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts, return i; } + /* check the data_len in mbuf */ + if (m->data_len < ICE_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/ice/ice_rxtx.h b/drivers/net/ice/ice_rxtx.h index a74c4b3492..1ba264ddbc 100644 --- a/drivers/net/ice/ice_rxtx.h +++ b/drivers/net/ice/ice_rxtx.h @@ -40,6 +40,8 @@ #define ICE_RXDID_COMMS_OVS 22 +#define ICE_TX_MIN_PKT_LEN 17 + typedef void (*ice_rx_release_mbufs_t)(struct ice_rx_queue *rxq); typedef void (*ice_tx_release_mbufs_t)(struct ice_tx_queue *txq); typedef void (*ice_rxd_to_pkt_fields_t)(struct ice_rx_queue *rxq, -- 2.34.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2022-11-03 09:27:28.521032733 +0000 +++ 0051-net-ice-check-illegal-packet-sizes.patch 2022-11-03 09:27:25.453423990 +0000 @@ -1 +1 @@ -From ccf33dccf7aaf208ef67ed7b8ef45d05bce5e3a5 Mon Sep 17 00:00:00 2001 +From 5d9ff0ecf09710cd71e42eca104aedb39d0a521d Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit ccf33dccf7aaf208ef67ed7b8ef45d05bce5e3a5 ] + @@ -16 +17,0 @@ -Cc: stable@dpdk.org @@ -26 +27 @@ -index 5af7c0c8f6..d1e1fadf9d 100644 +index 5f94b4174d..fe1f3eea2d 100644 @@ -29 +30 @@ -@@ -3442,6 +3442,9 @@ ice_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts, +@@ -3209,6 +3209,9 @@ ice_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts, @@ -39 +40 @@ -@@ -3458,6 +3461,14 @@ ice_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts, +@@ -3225,6 +3228,14 @@ ice_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts, @@ -51 +52 @@ - #ifdef RTE_ETHDEV_DEBUG_TX + #ifdef RTE_LIBRTE_ETHDEV_DEBUG @@ -55 +56 @@ -index 6c08c175dc..e1d4fe8e47 100644 +index a74c4b3492..1ba264ddbc 100644 @@ -64,3 +65,3 @@ - extern uint64_t ice_timestamp_dynflag; - extern int ice_timestamp_dynfield_offset; - + typedef void (*ice_rx_release_mbufs_t)(struct ice_rx_queue *rxq); + typedef void (*ice_tx_release_mbufs_t)(struct ice_tx_queue *txq); + typedef void (*ice_rxd_to_pkt_fields_t)(struct ice_rx_queue *rxq,