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 364D041C50; Fri, 10 Feb 2023 19:02:52 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F423B42C54; Fri, 10 Feb 2023 19:02:47 +0100 (CET) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id 1C4AE410EA; Fri, 10 Feb 2023 19:02:43 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676052164; x=1707588164; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hZuc1w9f+7sAd8qKVpDzlGkFmUSFZdLfm80AIdXMQNo=; b=T8ef08vX+mX2iWzvVBCAPgANGaImmf/o2sAs3NQtVhlsgQKWVMFoWeyQ GX9qpq7gjpfVNlhMfCB0i+JwvEQLRelor1K/2LPxQfXWXP7wEmGM/4wC5 h9Wtv3q34ALNu3zm7sfVMnEsRCPjwu+yVqpz6h4TWjMVxZwflZnXJtS3g UdZQ7XHFWIeyyHX1Qx2hZBQKda7wSO2136aHC+lmNmkA5eRRQk19Ym6fX 0OQJDJ5diVhXYrXRK8edE/PmduJFRwCYqfCrMeRMhYAISv8CIRqsSM9b4 PVxuOab7ikYcpPs32AZNS3VZHjUl8R4EHm9sE9739KHgxTqUrMNjsY8y0 Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10617"; a="310117901" X-IronPort-AV: E=Sophos;i="5.97,287,1669104000"; d="scan'208";a="310117901" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2023 10:02:14 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10617"; a="670076701" X-IronPort-AV: E=Sophos;i="5.97,287,1669104000"; d="scan'208";a="670076701" Received: from spr-npg-bds1-eec2.sn.intel.com (HELO spr-npg-bds1-eec2..) ([10.233.181.123]) by fmsmga007.fm.intel.com with ESMTP; 10 Feb 2023 10:02:14 -0800 From: Nicolas Chautru To: dev@dpdk.org, maxime.coquelin@redhat.com Cc: hernan.vargas@intel.com, stable@dpdk.org, Nicolas Chautru Subject: [PATCH v2 1/9] baseband/acc: protection for TB negative scenario Date: Fri, 10 Feb 2023 17:58:33 +0000 Message-Id: <20230210175841.303450-2-nicolas.chautru@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230210175841.303450-1-nicolas.chautru@intel.com> References: <20230209221929.265059-2-nicolas.chautru@intel.com> <20230210175841.303450-1-nicolas.chautru@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Adding handling of negative scenario for malformed Transport Block mode operations. Fixes: bec597b78a0 ("baseband/acc200: add LTE processing") Cc: stable@dpdk.org Signed-off-by: Nicolas Chautru Reviewed-by: Maxime Coquelin --- drivers/baseband/acc/rte_vrb_pmd.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/baseband/acc/rte_vrb_pmd.c b/drivers/baseband/acc/rte_vrb_pmd.c index 34e42d1f6e..3afaea71a3 100644 --- a/drivers/baseband/acc/rte_vrb_pmd.c +++ b/drivers/baseband/acc/rte_vrb_pmd.c @@ -1820,6 +1820,9 @@ enqueue_enc_one_op_tb(struct acc_queue *q, struct rte_bbdev_enc_op *op, r = op->turbo_enc.tb_params.r; while (mbuf_total_left > 0 && r < c) { + if (unlikely((input == NULL) || (output == NULL))) + return -1; + seg_total_left = rte_pktmbuf_data_len(input) - in_offset; /* Set up DMA descriptor */ desc = acc_desc(q, total_enqueued_cbs); @@ -1854,6 +1857,10 @@ enqueue_enc_one_op_tb(struct acc_queue *q, struct rte_bbdev_enc_op *op, r++; } + /* In case the number of CB doesn't match, the configuration was invalid. */ + if (unlikely(current_enqueued_cbs != cbs_in_tb)) + return -1; + /* Set SDone on last CB descriptor for TB mode. */ desc->req.sdone_enable = 1; @@ -2100,6 +2107,9 @@ vrb_enqueue_ldpc_dec_one_op_tb(struct acc_queue *q, struct rte_bbdev_dec_op *op, } while (mbuf_total_left > 0 && r < c) { + if (unlikely((input == NULL) || (h_output == NULL))) + return -1; + if (check_bit(op->ldpc_dec.op_flags, RTE_BBDEV_LDPC_DEC_SCATTER_GATHER)) seg_total_left = rte_pktmbuf_data_len(input) - in_offset; else @@ -2145,6 +2155,10 @@ vrb_enqueue_ldpc_dec_one_op_tb(struct acc_queue *q, struct rte_bbdev_dec_op *op, r++; } + /* In case the number of CB doesn't match, the configuration was invalid. */ + if (unlikely(current_enqueued_cbs != cbs_in_tb)) + return -1; + #ifdef RTE_LIBRTE_BBDEV_DEBUG if (check_mbuf_total_left(mbuf_total_left) != 0) return -EINVAL; @@ -2187,6 +2201,8 @@ enqueue_dec_one_op_tb(struct acc_queue *q, struct rte_bbdev_dec_op *op, r = op->turbo_dec.tb_params.r; while (mbuf_total_left > 0 && r < c) { + if (unlikely((input == NULL) || (h_output == NULL))) + return -1; seg_total_left = rte_pktmbuf_data_len(input) - in_offset; @@ -2237,6 +2253,10 @@ enqueue_dec_one_op_tb(struct acc_queue *q, struct rte_bbdev_dec_op *op, r++; } + /* In case the number of CB doesn't match, the configuration was invalid. */ + if (unlikely(current_enqueued_cbs != cbs_in_tb)) + return -1; + /* Set SDone on last CB descriptor for TB mode */ desc->req.sdone_enable = 1; -- 2.34.1