patch 'test/mem: disable ASan when accessing unallocated memory' has been queued to stable release 21.11.2

Kevin Traynor ktraynor at redhat.com
Wed May 25 18:27:53 CEST 2022


Hi,

FYI, your patch has been queued to stable release 21.11.2

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 05/30/22. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://github.com/kevintraynor/dpdk-stable

This queued commit can be viewed at:
https://github.com/kevintraynor/dpdk-stable/commit/03e1864411b8a198ee065d9dc2e24102ed262518

Thanks.

Kevin

---
>From 03e1864411b8a198ee065d9dc2e24102ed262518 Mon Sep 17 00:00:00 2001
From: David Marchand <david.marchand at redhat.com>
Date: Thu, 5 May 2022 11:29:51 +0200
Subject: [PATCH] test/mem: disable ASan when accessing unallocated memory

[ upstream commit 48ff13ef37cbd63ecba9b28d5377444964c9c49f ]

As described in bugzilla, ASan reports accesses to all memory segment as
invalid, since those parts have not been allocated with rte_malloc.
Move __rte_no_asan to rte_common.h and disable ASan on a part of the test.

Bugzilla ID: 880
Fixes: 6cc51b1293ce ("mem: instrument allocator for ASan")

Signed-off-by: David Marchand <david.marchand at redhat.com>
Acked-by: Anatoly Burakov <anatoly.burakov at intel.com>
---
 app/test/test_memory.c       |  5 +++++
 lib/eal/common/malloc_elem.h | 10 ++--------
 lib/eal/include/rte_common.h | 13 +++++++++++++
 3 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/app/test/test_memory.c b/app/test/test_memory.c
index 140ac3f3cf..440e5ef838 100644
--- a/app/test/test_memory.c
+++ b/app/test/test_memory.c
@@ -26,4 +26,9 @@
  */
 
+/*
+ * ASan complains about accessing unallocated memory.
+ * See: https://bugs.dpdk.org/show_bug.cgi?id=880
+ */
+__rte_no_asan
 static int
 check_mem(const struct rte_memseg_list *msl __rte_unused,
diff --git a/lib/eal/common/malloc_elem.h b/lib/eal/common/malloc_elem.h
index c5f26ffd2f..503fe5c470 100644
--- a/lib/eal/common/malloc_elem.h
+++ b/lib/eal/common/malloc_elem.h
@@ -8,4 +8,6 @@
 #include <stdbool.h>
 
+#include <rte_common.h>
+
 #define MIN_DATA_SIZE (RTE_CACHE_LINE_SIZE)
 
@@ -126,10 +128,4 @@ malloc_elem_cookies_ok(const struct malloc_elem *elem)
 	RTE_PTR_ADD(ASAN_MEM_SHIFT(mem), ASAN_SHADOW_OFFSET)
 
-#if defined(__clang__)
-#define __rte_no_asan __attribute__((no_sanitize("address", "hwaddress")))
-#else
-#define __rte_no_asan __attribute__((no_sanitize_address))
-#endif
-
 __rte_no_asan
 static inline void
@@ -271,6 +267,4 @@ old_malloc_size(struct malloc_elem *elem)
 #else /* !RTE_MALLOC_ASAN */
 
-#define __rte_no_asan
-
 static inline void
 asan_set_zone(void *ptr __rte_unused, size_t len __rte_unused,
diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h
index 4a399cc7c8..eee1ada379 100644
--- a/lib/eal/include/rte_common.h
+++ b/lib/eal/include/rte_common.h
@@ -243,4 +243,17 @@ static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void)
 #define __rte_cold __attribute__((cold))
 
+/**
+ * Disable AddressSanitizer on some code
+ */
+#ifdef RTE_MALLOC_ASAN
+#ifdef RTE_CC_CLANG
+#define __rte_no_asan __attribute__((no_sanitize("address", "hwaddress")))
+#else
+#define __rte_no_asan __attribute__((no_sanitize_address))
+#endif
+#else /* ! RTE_MALLOC_ASAN */
+#define __rte_no_asan
+#endif
+
 /*********** Macros for pointer arithmetic ********/
 
-- 
2.34.3

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2022-05-25 17:26:58.683524696 +0100
+++ 0001-test-mem-disable-ASan-when-accessing-unallocated-mem.patch	2022-05-25 17:26:58.525828270 +0100
@@ -1 +1 @@
-From 48ff13ef37cbd63ecba9b28d5377444964c9c49f Mon Sep 17 00:00:00 2001
+From 03e1864411b8a198ee065d9dc2e24102ed262518 Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit 48ff13ef37cbd63ecba9b28d5377444964c9c49f ]
+
@@ -12 +13,0 @@
-Cc: stable at dpdk.org
@@ -37 +38 @@
-index c5f65895e1..952ce7343b 100644
+index c5f26ffd2f..503fe5c470 100644
@@ -47 +48 @@
-@@ -132,10 +134,4 @@ malloc_elem_cookies_ok(const struct malloc_elem *elem)
+@@ -126,10 +128,4 @@ malloc_elem_cookies_ok(const struct malloc_elem *elem)
@@ -58 +59 @@
-@@ -277,6 +273,4 @@ old_malloc_size(struct malloc_elem *elem)
+@@ -271,6 +267,4 @@ old_malloc_size(struct malloc_elem *elem)
@@ -66 +67 @@
-index 67587025ab..d56a7570c0 100644
+index 4a399cc7c8..eee1ada379 100644
@@ -69 +70 @@
-@@ -268,4 +268,17 @@ static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void)
+@@ -243,4 +243,17 @@ static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void)



More information about the stable mailing list