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 75FBA45A58; Fri, 18 Oct 2024 09:59:18 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0C8DA4025F; Fri, 18 Oct 2024 09:59:18 +0200 (CEST) Received: from mx0a-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id CCD3D4003C for ; Fri, 18 Oct 2024 09:59:15 +0200 (CEST) Received: from pps.filterd (m0431384.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49I5AsGI016124 for ; Fri, 18 Oct 2024 00:59:14 -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=Nd1gk/+aaTdIzUC5CxhCL5V WKBuYhHtFMuWUfpa8FMo=; b=fsUxd8vnJNPM9Hvqe7OK/ORWnt7cT1i5ydFShh3 CuQFKDbwRvpcBXzJ+D7HGcfxh55QOiebN7+vXzJTvMyqWVcXlOjb1QKxBujsmYci xrTaFvJzgG95pUvaC6BHfuDqQn4aGUHCjFAAQQIUEOlF4BaIiRwtBtXZDRtv9Nva bpeoksYhhXoGVW0G8J2I76sSmd0qffcFBcxJFiEMMDcgasCCcp0Hm0TdzBu4Ggva AxBEGAc20divbw4By9y3rrwlIQB8tpMvnaBKXCQU/FHNkkO5VyuovWN5kMe89f3U VkwIq16tne9RmRRIiVBqIZ9crTmqehg7uIYh8USGWbKVzjg== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 42bha60apt-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 18 Oct 2024 00:59:14 -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, 18 Oct 2024 00:59:14 -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, 18 Oct 2024 00:59:13 -0700 Received: from localhost.localdomain (unknown [10.28.36.155]) by maili.marvell.com (Postfix) with ESMTP id 410243F706B; Fri, 18 Oct 2024 00:59:12 -0700 (PDT) From: Hanumanth Pothula To: Jerin Jacob CC: , , Subject: [PATCH] event/octeontx: resolve possible integer overflow Date: Fri, 18 Oct 2024 13:29:03 +0530 Message-ID: <20241018075903.53757-1-hpothula@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: KM-3G9nHxtIaDIm8sSMM0ZiGWN_p_UVC X-Proofpoint-GUID: KM-3G9nHxtIaDIm8sSMM0ZiGWN_p_UVC X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.687,Hydra:6.0.235,FMLib:17.0.607.475 definitions=2020-10-13_15,2020-10-13_02,2020-04-07_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 The last argument passed to ssovf_parsekv() is an unsigned char*, but it is accessed as an integer. This can lead to an integer overflow. Hence, make ensure the argument is accessed as a char and for better error handling use strtol instead of atoi. Signed-off-by: Hanumanth Pothula --- drivers/event/octeontx/ssovf_evdev.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/event/octeontx/ssovf_evdev.c b/drivers/event/octeontx/ssovf_evdev.c index 3a933b1db7..ccb447d33a 100644 --- a/drivers/event/octeontx/ssovf_evdev.c +++ b/drivers/event/octeontx/ssovf_evdev.c @@ -719,8 +719,16 @@ ssovf_close(struct rte_eventdev *dev) static int ssovf_parsekv(const char *key __rte_unused, const char *value, void *opaque) { - int *flag = opaque; - *flag = !!atoi(value); + uint8_t *flag = (uint8_t *)opaque; + char *end; + + errno = 0; + *flag = (uint8_t)strtol(value, &end, 2); + if ((errno != 0) || (value == end)) { + ssovf_log_err("fail to get key val ret:%d err:%d", *flag, errno); + return -EINVAL; + } + return 0; } -- 2.25.1