[v1] ethdev: fix address sanitizer bug

Message ID 20230316094808.3253873-1-adwivedi@marvell.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series [v1] ethdev: fix address sanitizer bug |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/github-robot: build success github build: passed
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/intel-Testing success Testing PASS
ci/intel-Functional fail Functional issues

Commit Message

Ankur Dwivedi March 16, 2023, 9:48 a.m. UTC
  With clang 10 compilation, the address sanitizer reports global buffer
overflow issue. The issue is observed during trace point registration
in rte_trace_point_emit_string, for strings in iterator structure.
As a workaround for this clang issue, this patch removes the
rte_trace_point_emit_string and instead adds rte_trace_point_emit_ptr
to capture the iterator pointer.

Bugzilla ID: 1184
Fixes: 6679cf21d608 ("ethdev: add trace points")

Signed-off-by: Ankur Dwivedi <adwivedi@marvell.com>
---
 lib/ethdev/ethdev_trace.h | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
  

Comments

Ferruh Yigit March 16, 2023, 12:06 p.m. UTC | #1
On 3/16/2023 9:48 AM, Ankur Dwivedi wrote:
> With clang 10 compilation, the address sanitizer reports global buffer
> overflow issue. The issue is observed during trace point registration
> in rte_trace_point_emit_string, for strings in iterator structure.
> As a workaround for this clang issue, this patch removes the
> rte_trace_point_emit_string and instead adds rte_trace_point_emit_ptr
> to capture the iterator pointer.
> 
> Bugzilla ID: 1184
> Fixes: 6679cf21d608 ("ethdev: add trace points")
> 
> Signed-off-by: Ankur Dwivedi <adwivedi@marvell.com>

Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>

Applied to dpdk-next-net/main, thanks.
  
Yuan, DukaiX March 17, 2023, 3:06 a.m. UTC | #2
> -----Original Message-----
> From: Ankur Dwivedi <adwivedi@marvell.com>
> Sent: 2023年3月16日 17:48
> To: dev@dpdk.org
> Cc: Yuan, DukaiX <dukaix.yuan@intel.com>; jerinj@marvell.com;
> thomas@monjalon.net; ferruh.yigit@amd.com;
> andrew.rybchenko@oktetlabs.ru; skori@marvell.com; Ankur Dwivedi
> <adwivedi@marvell.com>
> Subject: [PATCH v1] ethdev: fix address sanitizer bug
> 
> With clang 10 compilation, the address sanitizer reports global buffer
> overflow issue. The issue is observed during trace point registration in
> rte_trace_point_emit_string, for strings in iterator structure.
> As a workaround for this clang issue, this patch removes the
> rte_trace_point_emit_string and instead adds rte_trace_point_emit_ptr to
> capture the iterator pointer.
> 
> Bugzilla ID: 1184
> Fixes: 6679cf21d608 ("ethdev: add trace points")
> 
> Signed-off-by: Ankur Dwivedi <adwivedi@marvell.com>
> ---
Tested-by: Dukai Yuan<dukaix.yuan@intel.com>
  

Patch

diff --git a/lib/ethdev/ethdev_trace.h b/lib/ethdev/ethdev_trace.h
index c57ed08d36..3dc7d028b8 100644
--- a/lib/ethdev/ethdev_trace.h
+++ b/lib/ethdev/ethdev_trace.h
@@ -100,16 +100,14 @@  RTE_TRACE_POINT(
 RTE_TRACE_POINT(
 	rte_eth_trace_iterator_next,
 	RTE_TRACE_POINT_ARGS(const struct rte_dev_iterator *iter, uint16_t id),
-	rte_trace_point_emit_string(iter->bus_str);
-	rte_trace_point_emit_string(iter->cls_str);
+	rte_trace_point_emit_ptr(iter);
 	rte_trace_point_emit_u16(id);
 )
 
 RTE_TRACE_POINT(
 	rte_eth_trace_iterator_cleanup,
 	RTE_TRACE_POINT_ARGS(const struct rte_dev_iterator *iter),
-	rte_trace_point_emit_string(iter->bus_str);
-	rte_trace_point_emit_string(iter->cls_str);
+	rte_trace_point_emit_ptr(iter);
 )
 
 RTE_TRACE_POINT(