From patchwork Thu Feb 23 12:30:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ankur Dwivedi X-Patchwork-Id: 124452 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1351941D50; Thu, 23 Feb 2023 13:30:49 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3E1A7431C3; Thu, 23 Feb 2023 13:30:47 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id E99E2431BA for ; Thu, 23 Feb 2023 13:30:45 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31NBuGX3007300 for ; Thu, 23 Feb 2023 04:30:44 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=53J/MpDRvBFnwJeNMLpMPv3ND05+5nSQeCD0ks0nBhs=; b=Uar3TEn2Vz055oLxeHFTE9hGbQWn9ViFcPYzYDVdAN++1n0hDTBU5+eLOsio3rFZQoX/ 3bSgdfKurb6kUt95jm3qH6bacPUwI+qaHfDPYTj8F/BjXn53acqYkyDSZVvv0xfzZySH JGvFVIRWTafld0uHcqou3NRWdo4HypV/SzVT83fLBGCSrdLd/5ai6hESmAkmb9CmvBUn u/+unP4VNVEx8P4/G9PusJO1GK7gbztkX+8431T06DU9kmnEC3YLBzx2zJ1eJw84ORx8 DpCxdlBI3QDzvlqJoHoaphffZIfvXgPtoDnvEqW2DcDqoRuvBpApoe0bEFqhKXIbC2ee 3A== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3nwy8qj5wj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Thu, 23 Feb 2023 04:30:44 -0800 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 23 Feb 2023 04:30:42 -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.42 via Frontend Transport; Thu, 23 Feb 2023 04:30:42 -0800 Received: from localhost.localdomain (unknown [10.28.36.185]) by maili.marvell.com (Postfix) with ESMTP id 03A873F708C; Thu, 23 Feb 2023 04:30:40 -0800 (PST) From: Ankur Dwivedi To: CC: , Ankur Dwivedi Subject: [PATCH v1 1/2] ethdev: fix null pointer dereference Date: Thu, 23 Feb 2023 18:00:28 +0530 Message-ID: <20230223123029.2117781-2-adwivedi@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230223123029.2117781-1-adwivedi@marvell.com> References: <20230223123029.2117781-1-adwivedi@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: nUvElaDAbRINniCa60WV-E_jTCXWSfr- X-Proofpoint-ORIG-GUID: nUvElaDAbRINniCa60WV-E_jTCXWSfr- X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-23_06,2023-02-23_01,2023-02-09_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 speed_fec_capa pointer can be null. So dereferencing the pointer is removed and only the pointer is captured in trace function. Fixed few more trace functions in which null pointer can be dereferenced. Coverity issue: 383238 Bugzilla ID: 1162 Fixes: 6679cf21d608 ("ethdev: add trace points") Fixes: ed04fd4072e9 ("ethdev: add trace points for flow") Signed-off-by: Ankur Dwivedi --- lib/ethdev/ethdev_trace.h | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/lib/ethdev/ethdev_trace.h b/lib/ethdev/ethdev_trace.h index 53d1a71ff0..a13e33fe64 100644 --- a/lib/ethdev/ethdev_trace.h +++ b/lib/ethdev/ethdev_trace.h @@ -123,8 +123,7 @@ RTE_TRACE_POINT( RTE_TRACE_POINT_ARGS(uint16_t port_id, const struct rte_eth_dev_owner *owner, int ret), rte_trace_point_emit_u16(port_id); - rte_trace_point_emit_u64(owner->id); - rte_trace_point_emit_string(owner->name); + rte_trace_point_emit_ptr(owner); rte_trace_point_emit_int(ret); ) @@ -375,9 +374,7 @@ RTE_TRACE_POINT( rte_eth_trace_find_next_of, RTE_TRACE_POINT_ARGS(uint16_t port_id, const struct rte_device *parent), rte_trace_point_emit_u16(port_id); - rte_trace_point_emit_string(parent->name); - rte_trace_point_emit_string(parent->bus_info); - rte_trace_point_emit_int(parent->numa_node); + rte_trace_point_emit_ptr(parent); ) RTE_TRACE_POINT( @@ -869,8 +866,7 @@ RTE_TRACE_POINT( const struct rte_eth_fec_capa *speed_fec_capa, unsigned int num, int ret), rte_trace_point_emit_u16(port_id); - rte_trace_point_emit_u32(speed_fec_capa->speed); - rte_trace_point_emit_u32(speed_fec_capa->capa); + rte_trace_point_emit_ptr(speed_fec_capa); rte_trace_point_emit_u32(num); rte_trace_point_emit_int(ret); ) @@ -1416,8 +1412,7 @@ RTE_TRACE_POINT( const struct rte_flow_item *pattern, const struct rte_flow_action *actions, int ret), rte_trace_point_emit_u16(port_id); - rte_trace_point_emit_u32(attr->group); - rte_trace_point_emit_u32(attr->priority); + rte_trace_point_emit_ptr(attr); rte_trace_point_emit_ptr(pattern); rte_trace_point_emit_ptr(actions); rte_trace_point_emit_int(ret); @@ -1510,10 +1505,7 @@ RTE_TRACE_POINT( const struct rte_flow_item_flex_conf *conf, const struct rte_flow_item_flex_handle *handle), rte_trace_point_emit_u16(port_id); - rte_trace_point_emit_int(conf->tunnel); - rte_trace_point_emit_int(conf->nb_samples); - rte_trace_point_emit_int(conf->nb_inputs); - rte_trace_point_emit_int(conf->nb_outputs); + rte_trace_point_emit_ptr(conf); rte_trace_point_emit_ptr(handle); ) @@ -2308,8 +2300,7 @@ RTE_TRACE_POINT_FP( int ret), rte_trace_point_emit_u16(port_id); rte_trace_point_emit_ptr(flow); - rte_trace_point_emit_int(action->type); - rte_trace_point_emit_ptr(action->conf); + rte_trace_point_emit_ptr(action); rte_trace_point_emit_ptr(data); rte_trace_point_emit_int(ret); ) @@ -2349,14 +2340,8 @@ RTE_TRACE_POINT_FP( const struct rte_flow_indir_action_conf *conf, const struct rte_flow_action *action, const struct rte_flow_action_handle *handle), - uint8_t ingress = conf->ingress; - uint8_t egress = conf->egress; - uint8_t transfer = conf->transfer; - rte_trace_point_emit_u16(port_id); - rte_trace_point_emit_u8(ingress); - rte_trace_point_emit_u8(egress); - rte_trace_point_emit_u8(transfer); + rte_trace_point_emit_ptr(conf); rte_trace_point_emit_ptr(action); rte_trace_point_emit_ptr(handle); ) From patchwork Thu Feb 23 12:30:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ankur Dwivedi X-Patchwork-Id: 124453 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A6FAF41D50; Thu, 23 Feb 2023 13:31:46 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 982F54316E; Thu, 23 Feb 2023 13:31:46 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id ECB77400EF for ; Thu, 23 Feb 2023 13:31:44 +0100 (CET) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31NCPAIn007428 for ; Thu, 23 Feb 2023 04:31:43 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=T8T2D8GDTXv/CnIA+9TknosyJ3V6TwJBzH2Z4GWUP4Y=; b=Y5U8kma+r8MNkDRxs6Mqucs3iFXC6HNQ3KyDAHnxXHloceV88DmYXpMY+REj4wVfdThw TWdgQU1pVYRJPKEWcYV+Gdah6P9Mr6qVbTqqm4NFQcCPeHeONtWvz89lu8q0iopXLhcU pTTOS0ywowRQ4s1Y8hdCQ1wovfrZ0m8mETTvS7gRnprJ7pDYvPmric45rNBN4kEaHzD1 SqIpyq2t4hDsBmuF2aBMrv9qSuRqB8eCG3+/3eF41khhwY0mQ4Xwoz+nBLVRwA0yNL9D rMaooatzFmVDRkaJmsf6StW8JFDH8VqchsT+YytHHc9KHs+ebOSYeurLWFiHJL+cGHWA hQ== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3nwy5h1am7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Thu, 23 Feb 2023 04:30:48 -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.42; Thu, 23 Feb 2023 04:30:47 -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.42 via Frontend Transport; Thu, 23 Feb 2023 04:30:47 -0800 Received: from localhost.localdomain (unknown [10.28.36.185]) by maili.marvell.com (Postfix) with ESMTP id C20B63F708E; Thu, 23 Feb 2023 04:30:45 -0800 (PST) From: Ankur Dwivedi To: CC: , Ankur Dwivedi Subject: [PATCH v1 2/2] ethdev: pass structure pointer Date: Thu, 23 Feb 2023 18:00:29 +0530 Message-ID: <20230223123029.2117781-3-adwivedi@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230223123029.2117781-1-adwivedi@marvell.com> References: <20230223123029.2117781-1-adwivedi@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: T259LdMhxze_-0pH9lvZ_eLTyyGSlva4 X-Proofpoint-ORIG-GUID: T259LdMhxze_-0pH9lvZ_eLTyyGSlva4 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-23_06,2023-02-23_01,2023-02-09_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 rte_eth_xstat_name structure is of size 64 bytes. Instead of passing the structure as value it is passed as a pointer, to avoid copy of 64 bytes in function call stack. Signed-off-by: Ankur Dwivedi Acked-by: Ferruh Yigit --- lib/ethdev/ethdev_trace.h | 4 ++-- lib/ethdev/rte_ethdev.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/ethdev/ethdev_trace.h b/lib/ethdev/ethdev_trace.h index a13e33fe64..7518c902d1 100644 --- a/lib/ethdev/ethdev_trace.h +++ b/lib/ethdev/ethdev_trace.h @@ -551,11 +551,11 @@ RTE_TRACE_POINT( RTE_TRACE_POINT( rte_eth_trace_xstats_get_names, RTE_TRACE_POINT_ARGS(uint16_t port_id, int i, - struct rte_eth_xstat_name xstats_names, + const struct rte_eth_xstat_name *xstats_names, unsigned int size, int cnt_used_entries), rte_trace_point_emit_u16(port_id); rte_trace_point_emit_int(i); - rte_trace_point_emit_string(xstats_names.name); + rte_trace_point_emit_string(xstats_names->name); rte_trace_point_emit_u32(size); rte_trace_point_emit_int(cnt_used_entries); ) diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index 0266cc82ac..3b07e6feb8 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -3260,7 +3260,7 @@ rte_eth_xstats_get_names(uint16_t port_id, } for (i = 0; i < cnt_used_entries; i++) - rte_eth_trace_xstats_get_names(port_id, i, xstats_names[i], + rte_eth_trace_xstats_get_names(port_id, i, &xstats_names[i], size, cnt_used_entries); return cnt_used_entries;