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 B79BBA034F; Tue, 11 Jan 2022 13:50:21 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4840B426FC; Tue, 11 Jan 2022 13:50:21 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id D4FF8411AE for ; Tue, 11 Jan 2022 13:50:19 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 20BB2lNu013830; Tue, 11 Jan 2022 04:50:19 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=wym2VHoq1br0quoAWUn9NLgsIqgL1+GryDlvWyocUBA=; b=h77M+/V9vW/RUNDYv8GLJ15gNtoHYSxeD3i+eaW+lSovMkgOLskAVfJNOY+wsn0Q1RlX w9Uta+WAjDQis/hDkC2EgGWFwuVyEdyuq/I9KuMxdtHlr3/SRGEyO2GUt72TzMpQC4P5 1USzHPu6kCVTuvt9hCKVtf75kAVuyy5c9FJZoh6VMS1PSwK08d3yLEwGJTHdwqCDGrMU NQkwQya9sj1VpOBgBJgMpW5nK1486MsL4bo+JClJ/0XCIrhWz69twGERusTyry5bImkU t+n6+IZA/0Fl3IPtGmcI0H5wdDbDFy3L4+3iEeWND8n2Al80aBleA/ooJe1wZj4+tpZy VQ== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3dh8nm0a85-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 11 Jan 2022 04:50:19 -0800 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 11 Jan 2022 04:50:17 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Tue, 11 Jan 2022 04:50:17 -0800 Received: from localhost.localdomain (unknown [10.28.48.107]) by maili.marvell.com (Postfix) with ESMTP id B04153F70BB; Tue, 11 Jan 2022 04:50:15 -0800 (PST) From: Rahul Bhansali To: , , CC: Rahul Bhansali Subject: [PATCH] examples/l3fwd: resolve stack buffer overflow issue Date: Tue, 11 Jan 2022 18:20:05 +0530 Message-ID: <20220111125005.554635-1-rbhansali@marvell.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: 5I1HsqexwvRyIcIgFVMJ8vH7qzWFTiiw X-Proofpoint-ORIG-GUID: 5I1HsqexwvRyIcIgFVMJ8vH7qzWFTiiw X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-01-11_04,2022-01-11_01,2021-12-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 This patch fixes the stack buffer overflow error reported from AddressSanitizer. Function send_packetsx4() tries to access out of bound data from rte_mbuf and fill it into TX buffer even in the case where no pending packets (len = 0). Performance impact:- No ASAN error report:- ==819==ERROR: AddressSanitizer: stack-buffer-overflow on address 0xffffe2c0dcf0 at pc 0x0000005e791c bp 0xffffe2c0d7e0 sp 0xffffe2c0d800 READ of size 8 at 0xffffe2c0dcf0 thread T0 #0 0x5e7918 in send_packetsx4 ../examples/l3fwd/l3fwd_common.h:251 #1 0x5e7918 in send_packets_multi ../examples/l3fwd/l3fwd_neon.h:226 Signed-off-by: Rahul Bhansali --- examples/l3fwd/l3fwd_common.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/examples/l3fwd/l3fwd_common.h b/examples/l3fwd/l3fwd_common.h index 7d83ff641a..de77711f88 100644 --- a/examples/l3fwd/l3fwd_common.h +++ b/examples/l3fwd/l3fwd_common.h @@ -236,6 +236,9 @@ send_packetsx4(struct lcore_conf *qconf, uint16_t port, struct rte_mbuf *m[], /* copy rest of the packets into the TX buffer. */ len = num - n; + if (len == 0) + goto exit; + j = 0; switch (len % FWDSTEP) { while (j < len) { @@ -258,6 +261,7 @@ send_packetsx4(struct lcore_conf *qconf, uint16_t port, struct rte_mbuf *m[], } } +exit: qconf->tx_mbufs[port].len = len; } -- 2.25.1