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 88E0441C5D; Fri, 10 Feb 2023 09:17:33 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 73CD9410D0; Fri, 10 Feb 2023 09:17:33 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 96F4E427F2 for ; Fri, 10 Feb 2023 09:17:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676017051; 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=y/lWYi9GLFW0k6FAdbJg9qQVkIfB0EW2XToPsdeYxwA=; b=Hbn6K09aIa1oKWQIjbvvOSlrAY1wMs+gK4mRLvTvL8M3p15gWJGoWKouxyDmhNez4PSgob UywzA8obIyhVWtQxSDCxBJkQsk8B9oCCxVUda+CUCYckYH49AgNdqjI4/XfS4YlRYEu98i MT7phCaugjAac8eSNliaTTv4oun8znk= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-311-oeJxdEGPOWOqZe-Gwpd9Vw-1; Fri, 10 Feb 2023 03:17:25 -0500 X-MC-Unique: oeJxdEGPOWOqZe-Gwpd9Vw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 07F713C01E02; Fri, 10 Feb 2023 08:17:25 +0000 (UTC) Received: from [10.39.208.26] (unknown [10.39.208.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 24B6C1121315; Fri, 10 Feb 2023 08:17:23 +0000 (UTC) Message-ID: <3eddc59a-7907-f485-d67c-7ae756a0aa31@redhat.com> Date: Fri, 10 Feb 2023 09:17:22 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Subject: Re: [PATCH v1 1/9] baseband/acc: protection for TB negative scenario To: Nicolas Chautru , dev@dpdk.org Cc: hernan.vargas@intel.com, stable@dpdk.org References: <20230209221929.265059-1-nicolas.chautru@intel.com> <20230209221929.265059-2-nicolas.chautru@intel.com> From: Maxime Coquelin In-Reply-To: <20230209221929.265059-2-nicolas.chautru@intel.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 On 2/9/23 23:19, Nicolas Chautru wrote: > 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 > --- > 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..797330a5dd 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 (current_enqueued_cbs != cbs_in_tb) Maybe wrap it with unlikely()? > + 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 (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 (current_enqueued_cbs != cbs_in_tb) > + return -1; > + > /* Set SDone on last CB descriptor for TB mode */ > desc->req.sdone_enable = 1; > Reviewed-by: Maxime Coquelin Thanks, Maxime