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 BE0E345BB9; Thu, 24 Oct 2024 05:55:33 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9325843352; Thu, 24 Oct 2024 05:55:33 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 646224060F for ; Thu, 24 Oct 2024 05:55:32 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49NDGmuH028008; Wed, 23 Oct 2024 20:55:30 -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=x Xr6QaFRNnBO6xwNBHiIVWxeAQymkwaB7wOKYjYZBIA=; b=eEo1F0TNCy/JrujUp /3xFSzK7RN7pgRMTQvUv5PM/XYFEncI0Quk+ZeyA08gSyJMtCetGEdSYvcidC0CD cFE0Km7OMgu8w1tk9UYFPmq16oYrvgpawZ59n+vfX7vgAbWvl1uf6PmzqvkhYcFD Cs/8Mi8v4usKjF5LmmVT+IQ7WjgIKnXvVRPkO8NeKxvI9gAzqCGrT4L2fwH7mQjF BqwyK+VR1plMA2vt7l799/bjq76uYU+v727ek55A0fJXTSCj+kXKllUud2Slzd++ 0yB+N3kP/PI7oofIRpTpgWztQKjyGpyUUDu48WRQHTCluSZiRVaLAbswhD7eqvY5 6NT1Q== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 42f1vshttk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 23 Oct 2024 20:55:30 -0700 (PDT) Received: from DC5-EXCH05.marvell.com (10.69.176.209) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 23 Oct 2024 20:55:29 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Wed, 23 Oct 2024 20:55:29 -0700 Received: from localhost.localdomain (unknown [10.28.36.155]) by maili.marvell.com (Postfix) with ESMTP id A97D83F7089; Wed, 23 Oct 2024 20:55:27 -0700 (PDT) From: Hanumanth Pothula To: Jerin Jacob CC: , , , Subject: [PATCH v3 1/1] event/octeontx: resolve possible integer overflow Date: Thu, 24 Oct 2024 09:25:24 +0530 Message-ID: <20241024035524.1021926-1-hpothula@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241023071546.865609-1-hpothula@marvell.com> References: <20241023071546.865609-1-hpothula@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: oVCrFKYZlIsWKngup4psgNOJd9C1vWy0 X-Proofpoint-GUID: oVCrFKYZlIsWKngup4psgNOJd9C1vWy0 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 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 --- v2: use strtoul instead of strtol v3: Add value boundry check. Here, value can be either 0 or 1. --- drivers/event/octeontx/ssovf_evdev.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/event/octeontx/ssovf_evdev.c b/drivers/event/octeontx/ssovf_evdev.c index 3a933b1db7..957fcab04e 100644 --- a/drivers/event/octeontx/ssovf_evdev.c +++ b/drivers/event/octeontx/ssovf_evdev.c @@ -717,10 +717,20 @@ ssovf_close(struct rte_eventdev *dev) } static int -ssovf_parsekv(const char *key __rte_unused, const char *value, void *opaque) +ssovf_parsekv(const char *key, const char *value, void *opaque) { - int *flag = opaque; - *flag = !!atoi(value); + uint8_t *flag = opaque; + uint64_t v; + char *end; + + errno = 0; + v = strtoul(value, &end, 0); + if ((errno != 0) || (value == end) || *end != '\0' || v > 1) { + ssovf_log_err("invalid %s value %s", key, value); + return -EINVAL; + } + + *flag = !!v; return 0; } -- 2.25.1