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 8B5FE45978; Fri, 13 Sep 2024 09:07:33 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5E59142E4F; Fri, 13 Sep 2024 09:07:33 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id A910E427A7; Fri, 13 Sep 2024 09:07:31 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 48D64afF032575; Fri, 13 Sep 2024 00:07:31 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=k i4jyqdgF6JR9e5yfn/lvq2mvVtTS0IvdOCxx3H3bFw=; b=GQjONXsLPyNfqmbeY 4672jr5zUH/IAqq2So7BQz71dKUveObCt+4VOsQ0eO1QD3EbODHWxoCaXTVRd9Nn rh1DYfjBXrky/G4lL3PsFYnfCyOS+VXIKXrXwrFxyHkkxN25Idbgr2Lxkte8VHI7 YS+VxAhlZbOiOLi+abybbefQxnXU4oNER4it2flv+DzHrDhDKSAR2sc6PMUM5LZg qnlcHDe0TYhgAglrlEMa4Fgapq5qSmKynrYkY39sKub5lVzN3X5I9FsZgMBRXqbr 61h/xErQJFhEXyeDPOSxASp3LRxXJyffrTXZgMUjMwNCupFaLg5/hdxY5+h3dhrd 7aEIg== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 41ks8pxucw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 13 Sep 2024 00:07:30 -0700 (PDT) Received: from DC6WP-EXCH02.marvell.com (10.76.176.209) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 13 Sep 2024 00:07:30 -0700 Received: from maili.marvell.com (10.69.176.80) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Fri, 13 Sep 2024 00:07:30 -0700 Received: from hyd1554.caveonetworks.com (unknown [10.29.56.32]) by maili.marvell.com (Postfix) with ESMTP id 8D6243F7044; Fri, 13 Sep 2024 00:07:27 -0700 (PDT) From: Tejasree Kondoj To: Akhil Goyal , Radu Nicolau CC: Anoob Joseph , Nithin Dabilpuram , Jerin Jacob , , Subject: [PATCH v2] examples/ipsec-secgw: fix dequeue count from cryptodev Date: Fri, 13 Sep 2024 12:37:26 +0530 Message-ID: <20240913070726.1620828-1-ktejasree@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240913065800.1620605-1-ktejasree@marvell.com> References: <20240913065800.1620605-1-ktejasree@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: O6rEXSqhHeXls4WVQwymW2dDE8dyX4qz X-Proofpoint-GUID: O6rEXSqhHeXls4WVQwymW2dDE8dyX4qz X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 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 Setting dequeue packet count to max of MAX_PKT_BURST size instead of MAX_PKTS. Dequeue from cryptodev is called with MAX_PKTS but routing functions allocate hop/dst_ip arrays of size MAX_PKT_BURST. This can corrupt stack causing stack smashing error when more than MAX_PKT_BURST packets are returned from cryptodev. Fixes: a2b445b810ac ("examples/ipsec-secgw: allow larger burst size for vectors") Cc: stable@dpdk.org Signed-off-by: Tejasree Kondoj --- v2: fixed checkpatch warning examples/ipsec-secgw/ipsec-secgw.c | 6 ++++-- examples/ipsec-secgw/ipsec_process.c | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/examples/ipsec-secgw/ipsec-secgw.c b/examples/ipsec-secgw/ipsec-secgw.c index e98ad2572e..063cc8768e 100644 --- a/examples/ipsec-secgw/ipsec-secgw.c +++ b/examples/ipsec-secgw/ipsec-secgw.c @@ -626,12 +626,13 @@ drain_inbound_crypto_queues(const struct lcore_conf *qconf, uint32_t n; struct ipsec_traffic trf; unsigned int lcoreid = rte_lcore_id(); + const int nb_pkts = RTE_DIM(trf.ipsec.pkts); if (app_sa_prm.enable == 0) { /* dequeue packets from crypto-queue */ n = ipsec_inbound_cqp_dequeue(ctx, trf.ipsec.pkts, - RTE_DIM(trf.ipsec.pkts)); + RTE_MIN(MAX_PKT_BURST, nb_pkts)); trf.ip4.num = 0; trf.ip6.num = 0; @@ -663,12 +664,13 @@ drain_outbound_crypto_queues(const struct lcore_conf *qconf, { uint32_t n; struct ipsec_traffic trf; + const int nb_pkts = RTE_DIM(trf.ipsec.pkts); if (app_sa_prm.enable == 0) { /* dequeue packets from crypto-queue */ n = ipsec_outbound_cqp_dequeue(ctx, trf.ipsec.pkts, - RTE_DIM(trf.ipsec.pkts)); + RTE_MIN(MAX_PKT_BURST, nb_pkts)); trf.ip4.num = 0; trf.ip6.num = 0; diff --git a/examples/ipsec-secgw/ipsec_process.c b/examples/ipsec-secgw/ipsec_process.c index ddbe30745b..5080e810e0 100644 --- a/examples/ipsec-secgw/ipsec_process.c +++ b/examples/ipsec-secgw/ipsec_process.c @@ -336,6 +336,7 @@ ipsec_cqp_process(struct ipsec_ctx *ctx, struct ipsec_traffic *trf) struct rte_ipsec_session *ss; struct traffic_type *out; struct rte_ipsec_group *pg; + const int nb_cops = RTE_DIM(trf->ipsec.pkts); struct rte_crypto_op *cop[RTE_DIM(trf->ipsec.pkts)]; struct rte_ipsec_group grp[RTE_DIM(trf->ipsec.pkts)]; @@ -345,7 +346,7 @@ ipsec_cqp_process(struct ipsec_ctx *ctx, struct ipsec_traffic *trf) out = &trf->ipsec; /* dequeue completed crypto-ops */ - n = ctx_dequeue(ctx, cop, RTE_DIM(cop)); + n = ctx_dequeue(ctx, cop, RTE_MIN(MAX_PKT_BURST, nb_cops)); if (n == 0) return; -- 2.25.1