[PATCH 1/2] drivers: fix ASan ODR violation on glue symbols
Maayan Kashani
mkashani at nvidia.com
Tue Nov 3 12:25:24 CET 2026
With ibverbs linked by dlopen, a static PMD and its glue library
each define one global. net/mlx4 and librte_net_mlx4_glue both
define mlx4_glue. common/mlx5 and librte_common_mlx5_glue both
define mlx5_glue. This is not a clash between mlx4 and mlx5.
Only AddressSanitizer detects this collision. The linker keeps one
copy, so a normal process is unaffected. AddressSanitizer records
both definitions and aborts at startup.
Keep the name dlsym() looks up in the glue library. Point the PMD
at that table through a private symbol.
Fixes: a5e5af7f20b4 ("net/mlx4: fix build with -fno-common")
Cc: stable at dpdk.org
Signed-off-by: Maayan Kashani <mkashani at nvidia.com>
Acked-by: Bing Zhao <bingz at nvidia.com>
---
drivers/common/mlx5/linux/meson.build | 2 +-
drivers/common/mlx5/linux/mlx5_common_os.c | 4 ++--
drivers/common/mlx5/linux/mlx5_glue.h | 11 +++++++++++
drivers/net/mlx4/meson.build | 2 +-
drivers/net/mlx4/mlx4.c | 2 +-
drivers/net/mlx4/mlx4_glue.h | 11 +++++++++++
6 files changed, 27 insertions(+), 5 deletions(-)
diff --git a/drivers/common/mlx5/linux/meson.build b/drivers/common/mlx5/linux/meson.build
index 3767e7a69b6..038b76b8447 100644
--- a/drivers/common/mlx5/linux/meson.build
+++ b/drivers/common/mlx5/linux/meson.build
@@ -245,7 +245,7 @@ if dlopen_ibverbs
dlopen_lib_name,
dlopen_sources,
include_directories: dlopen_includes,
- c_args: cflags,
+ c_args: cflags + ['-DMLX5_GLUE_LIBRARY'],
dependencies: libs,
link_args: [
'-Wl,-export-dynamic',
diff --git a/drivers/common/mlx5/linux/mlx5_common_os.c b/drivers/common/mlx5/linux/mlx5_common_os.c
index 903963670db..b8a7c53e5f3 100644
--- a/drivers/common/mlx5/linux/mlx5_common_os.c
+++ b/drivers/common/mlx5/linux/mlx5_common_os.c
@@ -28,8 +28,8 @@
#include "mlx5_glue.h"
#ifdef MLX5_GLUE
-RTE_EXPORT_INTERNAL_SYMBOL(mlx5_glue)
-const struct mlx5_glue *mlx5_glue;
+RTE_EXPORT_INTERNAL_SYMBOL(mlx5_glue_handle)
+const mlx5_glue_t *mlx5_glue;
#endif
RTE_EXPORT_INTERNAL_SYMBOL(mlx5_get_pci_addr)
diff --git a/drivers/common/mlx5/linux/mlx5_glue.h b/drivers/common/mlx5/linux/mlx5_glue.h
index 0610e7778e1..38292c1346d 100644
--- a/drivers/common/mlx5/linux/mlx5_glue.h
+++ b/drivers/common/mlx5/linux/mlx5_glue.h
@@ -412,6 +412,17 @@ struct mlx5_glue {
int (*destroy_steering_anchor)(struct mlx5dv_steering_anchor *sa);
};
+#if defined(RTE_IBVERBS_LINK_DLOPEN) && !defined(MLX5_GLUE_LIBRARY)
+/*
+ * The PMD keeps the address of the glue table in a private symbol. The glue
+ * library exports mlx5_glue for lookup with dlsym().
+ */
+typedef struct mlx5_glue mlx5_glue_t;
+
+extern const mlx5_glue_t *mlx5_glue_handle;
+#define mlx5_glue mlx5_glue_handle
+#else
extern const struct mlx5_glue *mlx5_glue;
+#endif
#endif /* MLX5_GLUE_H_ */
diff --git a/drivers/net/mlx4/meson.build b/drivers/net/mlx4/meson.build
index 1eb67f3c472..fdef57f6812 100644
--- a/drivers/net/mlx4/meson.build
+++ b/drivers/net/mlx4/meson.build
@@ -125,7 +125,7 @@ if dlopen_ibverbs
dlopen_lib_name,
dlopen_sources,
include_directories: global_inc,
- c_args: cflags,
+ c_args: cflags + ['-DMLX4_GLUE_LIBRARY'],
dependencies: libs,
link_args: [
'-Wl,-export-dynamic',
diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c
index dbcd98d49f5..c5015bc03cb 100644
--- a/drivers/net/mlx4/mlx4.c
+++ b/drivers/net/mlx4/mlx4.c
@@ -50,7 +50,7 @@
#include "mlx4_utils.h"
#ifdef MLX4_GLUE
-const struct mlx4_glue *mlx4_glue;
+const mlx4_glue_t *mlx4_glue;
#endif
static const char *MZ_MLX4_PMD_SHARED_DATA = "mlx4_pmd_shared_data";
diff --git a/drivers/net/mlx4/mlx4_glue.h b/drivers/net/mlx4/mlx4_glue.h
index 96d5cb16b48..9209ce77cd5 100644
--- a/drivers/net/mlx4/mlx4_glue.h
+++ b/drivers/net/mlx4/mlx4_glue.h
@@ -83,6 +83,17 @@ struct mlx4_glue {
void *attr);
};
+#if defined(MLX4_GLUE) && !defined(MLX4_GLUE_LIBRARY)
+/*
+ * The PMD keeps the address of the glue table in a private symbol. The glue
+ * library exports mlx4_glue for lookup with dlsym().
+ */
+typedef struct mlx4_glue mlx4_glue_t;
+
+extern const mlx4_glue_t *mlx4_glue_handle;
+#define mlx4_glue mlx4_glue_handle
+#else
extern const struct mlx4_glue *mlx4_glue;
+#endif
#endif /* MLX4_GLUE_H_ */
--
2.25.1
More information about the stable
mailing list