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 7B7F545978; Fri, 13 Sep 2024 08:58:08 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C470442E7D; Fri, 13 Sep 2024 08:58:07 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id D5D064028F; Fri, 13 Sep 2024 08:58:05 +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 48D670FU032591; Thu, 12 Sep 2024 23:58:05 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to; s=pfpt0220; bh=o/xgmEpTaeRRyfjM1CoDLTo yIs8NklYRzNhp9FrC/sM=; b=RtcdmK31tyi/d2ELwdP/ZM2CWu8JpKR0rADUzKJ q+Ht5+utGFsQPBv0tPjsWNg8HxQqEJfCv50sKqRFPfWgqxCV1EFfejfU4Snq8odn HUXMN1Vb/Qea26s+Z6ZvPPsbFP+FCEhZdLJLJYgxuciqx40/EH7QFDuqQt6SbJXP fCAh2l/Eh3VuFCuA70kVMMK9WajLQQq31gcYKqc7DrUoJpfADLruBYOIMqb/E/ji jDM1jeipsPCVRsylKbQnNgd7Ld4UGCq5KH2H2A5TAQl/TOz35bZzE9fXOqXQbUtM BLqnwGW8+Q1bGw1HYDYrZh6qG8zotxVm/M9XNbUvpHKrqow== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 41ks8pxte4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Sep 2024 23:58:04 -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; Thu, 12 Sep 2024 23:58:04 -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; Thu, 12 Sep 2024 23:58:04 -0700 Received: from hyd1554.caveonetworks.com (unknown [10.29.56.32]) by maili.marvell.com (Postfix) with ESMTP id C50623F704C; Thu, 12 Sep 2024 23:58:01 -0700 (PDT) From: Tejasree Kondoj To: Akhil Goyal , Radu Nicolau CC: Anoob Joseph , Nithin Dabilpuram , Jerin Jacob , , Subject: [PATCH] examples/ipsec-secgw: fix dequeue count from cryptodev Date: Fri, 13 Sep 2024 12:28:00 +0530 Message-ID: <20240913065800.1620605-1-ktejasree@marvell.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: hY92TfGSIVLeH3VlzhHlN3WlXVOjXlsD X-Proofpoint-GUID: hY92TfGSIVLeH3VlzhHlN3WlXVOjXlsD 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 Change-Id: I3ab1b6d3aef5385f214f51930bfd521e73255834 --- 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