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 D87EFA054A for ; Tue, 25 Oct 2022 17:09:41 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BF46142C5A; Tue, 25 Oct 2022 17:09:41 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id B5F7542C3C for ; Tue, 25 Oct 2022 17:09:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666710580; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oNActf6frSQ6xUziv6XIw9ctJXcYtx9nnBl+ChTxlh4=; b=ezPFDwbYWyKGLwPdSyHCI88u+xi7kltnpMSRyoYSGvdKAhwhxCtdLeZ9SYZv1ALnywGA5X 8zEVorXG4s48lTTXf1Y9hlJ1D9aMmk9udS3H7rMCp2Jr31XhXJhbv+c89vryE3BfLV3Z6P sujsK0EdBFkMyv1mMrSOHE56v5uavCo= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-102-klQtj87gPbGTGo9AGtlgPQ-1; Tue, 25 Oct 2022 11:09:38 -0400 X-MC-Unique: klQtj87gPbGTGo9AGtlgPQ-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3E079101A588; Tue, 25 Oct 2022 15:09:38 +0000 (UTC) Received: from rh.redhat.com (unknown [10.39.192.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4DF0E47505E; Tue, 25 Oct 2022 15:09:37 +0000 (UTC) From: Kevin Traynor To: Kevin Liu Cc: Qi Zhang , dpdk stable Subject: patch 'net/iavf: check illegal packet sizes' has been queued to stable release 21.11.3 Date: Tue, 25 Oct 2022 16:07:07 +0100 Message-Id: <20221025150734.142189-72-ktraynor@redhat.com> In-Reply-To: <20221025150734.142189-1-ktraynor@redhat.com> References: <20221025150734.142189-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true 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 21.11.3 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/01/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/60f243aee8f548a1380d707687ae736719da24cb Thanks. Kevin --- >From 60f243aee8f548a1380d707687ae736719da24cb 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 | 9 +++++++++ drivers/net/iavf/iavf_rxtx.h | 2 ++ 2 files changed, 11 insertions(+) diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c index 7be759c791..45d75d46f7 100644 --- a/drivers/net/iavf/iavf_rxtx.c +++ b/drivers/net/iavf/iavf_rxtx.c @@ -2761,4 +2761,5 @@ iavf_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts, 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; 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); @@ -2789,4 +2790,12 @@ iavf_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts, } + /* 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_ETHDEV_DEBUG_TX ret = rte_validate_tx_offload(m); diff --git a/drivers/net/iavf/iavf_rxtx.h b/drivers/net/iavf/iavf_rxtx.h index 48cc0da6f5..743ff5e9d8 100644 --- a/drivers/net/iavf/iavf_rxtx.h +++ b/drivers/net/iavf/iavf_rxtx.h @@ -54,4 +54,6 @@ #define IAVF_TX_MAX_MTU_SEG 8 +#define IAVF_TX_MIN_PKT_LEN 17 + #define IAVF_TX_CKSUM_OFFLOAD_MASK ( \ RTE_MBUF_F_TX_IP_CKSUM | \ -- 2.37.3 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2022-10-25 14:19:00.183433577 +0100 +++ 0072-net-iavf-check-illegal-packet-sizes.patch 2022-10-25 14:18:58.497798399 +0100 @@ -1 +1 @@ -From 19ee91c6bd9a196b17394d69b18576a7ff8e2489 Mon Sep 17 00:00:00 2001 +From 60f243aee8f548a1380d707687ae736719da24cb Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 19ee91c6bd9a196b17394d69b18576a7ff8e2489 ] + @@ -16 +17,0 @@ -Cc: stable@dpdk.org @@ -26 +27 @@ -index fc5d9e38cc..89a1d141ba 100644 +index 7be759c791..45d75d46f7 100644 @@ -29 +30 @@ -@@ -2917,4 +2917,5 @@ iavf_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts, +@@ -2761,4 +2761,5 @@ iavf_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts, @@ -35 +36 @@ -@@ -2945,4 +2946,12 @@ iavf_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts, +@@ -2789,4 +2790,12 @@ iavf_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts, @@ -49 +50 @@ -index 66e832713c..3c89303980 100644 +index 48cc0da6f5..743ff5e9d8 100644 @@ -52 +53 @@ -@@ -56,4 +56,6 @@ +@@ -54,4 +54,6 @@