* [dpdk-dev] [PATCH] build: enable ASan for arm64
@ 2021-11-08 13:45 Volodymyr Fialko
2021-11-08 15:01 ` David Marchand
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Volodymyr Fialko @ 2021-11-08 13:45 UTC (permalink / raw)
To: dev, Bruce Richardson, Anatoly Burakov; +Cc: jerinj, Volodymyr Fialko
This patch defines ASAN_SHADOW_OFFSET for arm64 according to the ASan
documentation. This offset should cover all arm64 VMAs supported by
ASan.
Signed-off-by: Volodymyr Fialko <vfialko@marvell.com>
---
config/meson.build | 2 +-
doc/guides/prog_guide/asan.rst | 2 +-
lib/eal/common/malloc_elem.h | 3 +++
3 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/config/meson.build b/config/meson.build
index 17b5bec406..7eb710c08d 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -428,7 +428,7 @@ if get_option('b_sanitize') == 'address' or get_option('b_sanitize') == 'address
dpdk_extra_ldflags += '-lasan'
endif
- if is_linux and arch_subdir == 'x86' and dpdk_conf.get('RTE_ARCH_64')
+ if is_linux and arch_subdir in ['x86', 'arm'] and dpdk_conf.get('RTE_ARCH_64')
dpdk_conf.set10('RTE_MALLOC_ASAN', true)
endif
endif
diff --git a/doc/guides/prog_guide/asan.rst b/doc/guides/prog_guide/asan.rst
index 6d1b871c93..7a584427dd 100644
--- a/doc/guides/prog_guide/asan.rst
+++ b/doc/guides/prog_guide/asan.rst
@@ -33,7 +33,7 @@ Example::
"stty echo" command when an error occurs.
ASan is aware of DPDK memory allocations, thanks to added instrumentation.
-This is only enabled on x86_64 at the moment.
+This is only enabled on x86_64 and arm64 at the moment.
Other architectures may have to define ASAN_SHADOW_OFFSET.
Example heap-buffer-overflow error
diff --git a/lib/eal/common/malloc_elem.h b/lib/eal/common/malloc_elem.h
index 262d69bb3e..c00c7845ab 100644
--- a/lib/eal/common/malloc_elem.h
+++ b/lib/eal/common/malloc_elem.h
@@ -107,6 +107,9 @@ malloc_elem_cookies_ok(const struct malloc_elem *elem)
#ifdef RTE_ARCH_X86_64
#define ASAN_SHADOW_OFFSET 0x00007fff8000
#endif
+#ifdef RTE_ARCH_ARM64
+#define ASAN_SHADOW_OFFSET 0x001000000000
+#endif
#define ASAN_SHADOW_GRAIN_SIZE 8
#define ASAN_MEM_FREE_FLAG 0xfd
--
2.25.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [dpdk-dev] [PATCH] build: enable ASan for arm64
2021-11-08 13:45 [dpdk-dev] [PATCH] build: enable ASan for arm64 Volodymyr Fialko
@ 2021-11-08 15:01 ` David Marchand
2021-11-08 16:37 ` Jerin Jacob
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: David Marchand @ 2021-11-08 15:01 UTC (permalink / raw)
To: Volodymyr Fialko
Cc: dev, Bruce Richardson, Anatoly Burakov,
Jerin Jacob Kollanukkaran, David Christensen
On Mon, Nov 8, 2021 at 2:46 PM Volodymyr Fialko <vfialko@marvell.com> wrote:
>
> This patch defines ASAN_SHADOW_OFFSET for arm64 according to the ASan
> documentation. This offset should cover all arm64 VMAs supported by
> ASan.
>
> Signed-off-by: Volodymyr Fialko <vfialko@marvell.com>
> ---
> config/meson.build | 2 +-
> doc/guides/prog_guide/asan.rst | 2 +-
> lib/eal/common/malloc_elem.h | 3 +++
> 3 files changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/config/meson.build b/config/meson.build
> index 17b5bec406..7eb710c08d 100644
> --- a/config/meson.build
> +++ b/config/meson.build
> @@ -428,7 +428,7 @@ if get_option('b_sanitize') == 'address' or get_option('b_sanitize') == 'address
> dpdk_extra_ldflags += '-lasan'
> endif
>
> - if is_linux and arch_subdir == 'x86' and dpdk_conf.get('RTE_ARCH_64')
> + if is_linux and arch_subdir in ['x86', 'arm'] and dpdk_conf.get('RTE_ARCH_64')
> dpdk_conf.set10('RTE_MALLOC_ASAN', true)
> endif
> endif
> diff --git a/doc/guides/prog_guide/asan.rst b/doc/guides/prog_guide/asan.rst
> index 6d1b871c93..7a584427dd 100644
> --- a/doc/guides/prog_guide/asan.rst
> +++ b/doc/guides/prog_guide/asan.rst
> @@ -33,7 +33,7 @@ Example::
> "stty echo" command when an error occurs.
>
> ASan is aware of DPDK memory allocations, thanks to added instrumentation.
> -This is only enabled on x86_64 at the moment.
> +This is only enabled on x86_64 and arm64 at the moment.
Nit: "only" can be removed now.
> Other architectures may have to define ASAN_SHADOW_OFFSET.
>
> Example heap-buffer-overflow error
> diff --git a/lib/eal/common/malloc_elem.h b/lib/eal/common/malloc_elem.h
> index 262d69bb3e..c00c7845ab 100644
> --- a/lib/eal/common/malloc_elem.h
> +++ b/lib/eal/common/malloc_elem.h
> @@ -107,6 +107,9 @@ malloc_elem_cookies_ok(const struct malloc_elem *elem)
> #ifdef RTE_ARCH_X86_64
> #define ASAN_SHADOW_OFFSET 0x00007fff8000
> #endif
> +#ifdef RTE_ARCH_ARM64
> +#define ASAN_SHADOW_OFFSET 0x001000000000
> +#endif
The value lgtm, from gcc:
libsanitizer/asan/asan_mapping.h:static const u64
kAArch64_ShadowOffset64 = 1ULL << 36;
libsanitizer/asan/asan_mapping.h:# define SHADOW_OFFSET
kAArch64_ShadowOffset64
>
> #define ASAN_SHADOW_GRAIN_SIZE 8
> #define ASAN_MEM_FREE_FLAG 0xfd
> --
> 2.25.1
>
Reviewed-by: David Marchand <david.marchand@redhat.com>
I hope ppc will follow soon :-).
--
David Marchand
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [dpdk-dev] [PATCH] build: enable ASan for arm64
2021-11-08 13:45 [dpdk-dev] [PATCH] build: enable ASan for arm64 Volodymyr Fialko
2021-11-08 15:01 ` David Marchand
@ 2021-11-08 16:37 ` Jerin Jacob
2021-11-08 22:45 ` [dpdk-dev] [PATCH v2] eal/arm64: support ASan Volodymyr Fialko
2021-11-09 9:59 ` [dpdk-dev] [PATCH v3] " Volodymyr Fialko
3 siblings, 0 replies; 7+ messages in thread
From: Jerin Jacob @ 2021-11-08 16:37 UTC (permalink / raw)
To: Volodymyr Fialko, Ruifeng Wang (Arm Technology China),
Honnappa Nagarahalli
Cc: dpdk-dev, Bruce Richardson, Anatoly Burakov, Jerin Jacob
On Mon, Nov 8, 2021 at 7:16 PM Volodymyr Fialko <vfialko@marvell.com> wrote:
>
> This patch defines ASAN_SHADOW_OFFSET for arm64 according to the ASan
> documentation. This offset should cover all arm64 VMAs supported by
> ASan.
>
> Signed-off-by: Volodymyr Fialko <vfialko@marvell.com>
++ Arm maintainers
Prefer to change the subject to eal/arm64: support ASan
> ---
> config/meson.build | 2 +-
> doc/guides/prog_guide/asan.rst | 2 +-
> lib/eal/common/malloc_elem.h | 3 +++
> 3 files changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/config/meson.build b/config/meson.build
> index 17b5bec406..7eb710c08d 100644
> --- a/config/meson.build
> +++ b/config/meson.build
> @@ -428,7 +428,7 @@ if get_option('b_sanitize') == 'address' or get_option('b_sanitize') == 'address
> dpdk_extra_ldflags += '-lasan'
> endif
>
> - if is_linux and arch_subdir == 'x86' and dpdk_conf.get('RTE_ARCH_64')
> + if is_linux and arch_subdir in ['x86', 'arm'] and dpdk_conf.get('RTE_ARCH_64')
> dpdk_conf.set10('RTE_MALLOC_ASAN', true)
> endif
> endif
> diff --git a/doc/guides/prog_guide/asan.rst b/doc/guides/prog_guide/asan.rst
> index 6d1b871c93..7a584427dd 100644
> --- a/doc/guides/prog_guide/asan.rst
> +++ b/doc/guides/prog_guide/asan.rst
> @@ -33,7 +33,7 @@ Example::
> "stty echo" command when an error occurs.
>
> ASan is aware of DPDK memory allocations, thanks to added instrumentation.
> -This is only enabled on x86_64 at the moment.
> +This is only enabled on x86_64 and arm64 at the moment.
> Other architectures may have to define ASAN_SHADOW_OFFSET.
>
> Example heap-buffer-overflow error
> diff --git a/lib/eal/common/malloc_elem.h b/lib/eal/common/malloc_elem.h
> index 262d69bb3e..c00c7845ab 100644
> --- a/lib/eal/common/malloc_elem.h
> +++ b/lib/eal/common/malloc_elem.h
> @@ -107,6 +107,9 @@ malloc_elem_cookies_ok(const struct malloc_elem *elem)
> #ifdef RTE_ARCH_X86_64
> #define ASAN_SHADOW_OFFSET 0x00007fff8000
> #endif
> +#ifdef RTE_ARCH_ARM64
Better to change to "else if" to be more foolproof
> +#define ASAN_SHADOW_OFFSET 0x001000000000
Add a minimal comment on why this value was selected instead of x86
value of 0x00007fff8000
With the above change,
Acked-by: Jerin Jacob <jerinj@marvell.com>
> +#endif
>
> #define ASAN_SHADOW_GRAIN_SIZE 8
> #define ASAN_MEM_FREE_FLAG 0xfd
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [dpdk-dev] [PATCH v2] eal/arm64: support ASan
2021-11-08 13:45 [dpdk-dev] [PATCH] build: enable ASan for arm64 Volodymyr Fialko
2021-11-08 15:01 ` David Marchand
2021-11-08 16:37 ` Jerin Jacob
@ 2021-11-08 22:45 ` Volodymyr Fialko
2021-11-09 5:39 ` Ruifeng Wang
2021-11-09 9:59 ` [dpdk-dev] [PATCH v3] " Volodymyr Fialko
3 siblings, 1 reply; 7+ messages in thread
From: Volodymyr Fialko @ 2021-11-08 22:45 UTC (permalink / raw)
To: dev, Bruce Richardson, Anatoly Burakov
Cc: jerinj, Volodymyr Fialko, David Marchand
This patch defines ASAN_SHADOW_OFFSET for arm64 according to the ASan
documentation. This offset should cover all arm64 VMAs supported by
ASan.
Signed-off-by: Volodymyr Fialko <vfialko@marvell.com>
Reviewed-by: David Marchand <david.marchand@redhat.com>
Acked-by: Jerin Jacob <jerinj@marvell.com>
---
Changes since v1:
- changed the subject
- rewrite checks in "elif" manner
---
config/meson.build | 2 +-
doc/guides/prog_guide/asan.rst | 2 +-
lib/eal/common/malloc_elem.h | 2 ++
3 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/config/meson.build b/config/meson.build
index 17b5bec406..7eb710c08d 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -428,7 +428,7 @@ if get_option('b_sanitize') == 'address' or get_option('b_sanitize') == 'address
dpdk_extra_ldflags += '-lasan'
endif
- if is_linux and arch_subdir == 'x86' and dpdk_conf.get('RTE_ARCH_64')
+ if is_linux and arch_subdir in ['x86', 'arm'] and dpdk_conf.get('RTE_ARCH_64')
dpdk_conf.set10('RTE_MALLOC_ASAN', true)
endif
endif
diff --git a/doc/guides/prog_guide/asan.rst b/doc/guides/prog_guide/asan.rst
index 6d1b871c93..28b2382fc7 100644
--- a/doc/guides/prog_guide/asan.rst
+++ b/doc/guides/prog_guide/asan.rst
@@ -33,7 +33,7 @@ Example::
"stty echo" command when an error occurs.
ASan is aware of DPDK memory allocations, thanks to added instrumentation.
-This is only enabled on x86_64 at the moment.
+This is enabled on x86_64 and arm64 at the moment.
Other architectures may have to define ASAN_SHADOW_OFFSET.
Example heap-buffer-overflow error
diff --git a/lib/eal/common/malloc_elem.h b/lib/eal/common/malloc_elem.h
index 262d69bb3e..26e937cea0 100644
--- a/lib/eal/common/malloc_elem.h
+++ b/lib/eal/common/malloc_elem.h
@@ -106,6 +106,8 @@ malloc_elem_cookies_ok(const struct malloc_elem *elem)
#ifdef RTE_ARCH_X86_64
#define ASAN_SHADOW_OFFSET 0x00007fff8000
+#elif defined(RTE_ARCH_ARM64)
+#define ASAN_SHADOW_OFFSET 0x001000000000
#endif
#define ASAN_SHADOW_GRAIN_SIZE 8
--
2.25.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [dpdk-dev] [PATCH v2] eal/arm64: support ASan
2021-11-08 22:45 ` [dpdk-dev] [PATCH v2] eal/arm64: support ASan Volodymyr Fialko
@ 2021-11-09 5:39 ` Ruifeng Wang
0 siblings, 0 replies; 7+ messages in thread
From: Ruifeng Wang @ 2021-11-09 5:39 UTC (permalink / raw)
To: Volodymyr Fialko, dev, Bruce Richardson, Anatoly Burakov
Cc: jerinj, David Marchand, nd
> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Volodymyr Fialko
> Sent: Tuesday, November 9, 2021 6:46 AM
> To: dev@dpdk.org; Bruce Richardson <bruce.richardson@intel.com>;
> Anatoly Burakov <anatoly.burakov@intel.com>
> Cc: jerinj@marvell.com; Volodymyr Fialko <vfialko@marvell.com>; David
> Marchand <david.marchand@redhat.com>
> Subject: [dpdk-dev] [PATCH v2] eal/arm64: support ASan
>
> This patch defines ASAN_SHADOW_OFFSET for arm64 according to the ASan
> documentation. This offset should cover all arm64 VMAs supported by ASan.
>
> Signed-off-by: Volodymyr Fialko <vfialko@marvell.com>
> Reviewed-by: David Marchand <david.marchand@redhat.com>
> Acked-by: Jerin Jacob <jerinj@marvell.com>
> ---
> Changes since v1:
> - changed the subject
> - rewrite checks in "elif" manner
> ---
> config/meson.build | 2 +-
> doc/guides/prog_guide/asan.rst | 2 +-
> lib/eal/common/malloc_elem.h | 2 ++
> 3 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/config/meson.build b/config/meson.build index
> 17b5bec406..7eb710c08d 100644
> --- a/config/meson.build
> +++ b/config/meson.build
> @@ -428,7 +428,7 @@ if get_option('b_sanitize') == 'address' or
> get_option('b_sanitize') == 'address
> dpdk_extra_ldflags += '-lasan'
> endif
>
> - if is_linux and arch_subdir == 'x86' and dpdk_conf.get('RTE_ARCH_64')
> + if is_linux and arch_subdir in ['x86', 'arm'] and
> + dpdk_conf.get('RTE_ARCH_64')
> dpdk_conf.set10('RTE_MALLOC_ASAN', true)
> endif
> endif
> diff --git a/doc/guides/prog_guide/asan.rst
> b/doc/guides/prog_guide/asan.rst index 6d1b871c93..28b2382fc7 100644
> --- a/doc/guides/prog_guide/asan.rst
> +++ b/doc/guides/prog_guide/asan.rst
> @@ -33,7 +33,7 @@ Example::
> "stty echo" command when an error occurs.
>
> ASan is aware of DPDK memory allocations, thanks to added instrumentation.
> -This is only enabled on x86_64 at the moment.
> +This is enabled on x86_64 and arm64 at the moment.
> Other architectures may have to define ASAN_SHADOW_OFFSET.
>
> Example heap-buffer-overflow error
> diff --git a/lib/eal/common/malloc_elem.h b/lib/eal/common/malloc_elem.h
> index 262d69bb3e..26e937cea0 100644
> --- a/lib/eal/common/malloc_elem.h
> +++ b/lib/eal/common/malloc_elem.h
> @@ -106,6 +106,8 @@ malloc_elem_cookies_ok(const struct malloc_elem
> *elem)
>
> #ifdef RTE_ARCH_X86_64
> #define ASAN_SHADOW_OFFSET 0x00007fff8000
> +#elif defined(RTE_ARCH_ARM64)
> +#define ASAN_SHADOW_OFFSET 0x001000000000
As Jerin mentioned, it is better to add a comment on why this value was selected.
My search told me that "this value has to match kAArch64_ShadowOffset64 as defined
in libsanitizer/asan/asan_mapping.h".
With the change,
Acked-by: Ruifeng Wang <ruifeng.wang@arm.com>
> #endif
>
> #define ASAN_SHADOW_GRAIN_SIZE 8
> --
> 2.25.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [dpdk-dev] [PATCH v3] eal/arm64: support ASan
2021-11-08 13:45 [dpdk-dev] [PATCH] build: enable ASan for arm64 Volodymyr Fialko
` (2 preceding siblings ...)
2021-11-08 22:45 ` [dpdk-dev] [PATCH v2] eal/arm64: support ASan Volodymyr Fialko
@ 2021-11-09 9:59 ` Volodymyr Fialko
2021-11-12 13:34 ` David Marchand
3 siblings, 1 reply; 7+ messages in thread
From: Volodymyr Fialko @ 2021-11-09 9:59 UTC (permalink / raw)
To: dev, Bruce Richardson, Anatoly Burakov
Cc: jerinj, Volodymyr Fialko, David Marchand, Ruifeng Wang
This patch defines ASAN_SHADOW_OFFSET for arm64 according to the ASan
documentation. This offset should cover all arm64 VMAs supported by
ASan.
Signed-off-by: Volodymyr Fialko <vfialko@marvell.com>
Reviewed-by: David Marchand <david.marchand@redhat.com>
Acked-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Ruifeng Wang <ruifeng.wang@arm.com>
---
Changes since v2:
- added a comment that describes origin of the ASan shadow offset
Changes since v1:
- changed the subject
- rewrite checks in "elif" manner
---
config/meson.build | 2 +-
doc/guides/prog_guide/asan.rst | 2 +-
lib/eal/common/malloc_elem.h | 6 ++++++
3 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/config/meson.build b/config/meson.build
index 17b5bec406..7eb710c08d 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -428,7 +428,7 @@ if get_option('b_sanitize') == 'address' or get_option('b_sanitize') == 'address
dpdk_extra_ldflags += '-lasan'
endif
- if is_linux and arch_subdir == 'x86' and dpdk_conf.get('RTE_ARCH_64')
+ if is_linux and arch_subdir in ['x86', 'arm'] and dpdk_conf.get('RTE_ARCH_64')
dpdk_conf.set10('RTE_MALLOC_ASAN', true)
endif
endif
diff --git a/doc/guides/prog_guide/asan.rst b/doc/guides/prog_guide/asan.rst
index 6d1b871c93..28b2382fc7 100644
--- a/doc/guides/prog_guide/asan.rst
+++ b/doc/guides/prog_guide/asan.rst
@@ -33,7 +33,7 @@ Example::
"stty echo" command when an error occurs.
ASan is aware of DPDK memory allocations, thanks to added instrumentation.
-This is only enabled on x86_64 at the moment.
+This is enabled on x86_64 and arm64 at the moment.
Other architectures may have to define ASAN_SHADOW_OFFSET.
Example heap-buffer-overflow error
diff --git a/lib/eal/common/malloc_elem.h b/lib/eal/common/malloc_elem.h
index 262d69bb3e..de14d22a62 100644
--- a/lib/eal/common/malloc_elem.h
+++ b/lib/eal/common/malloc_elem.h
@@ -104,8 +104,14 @@ malloc_elem_cookies_ok(const struct malloc_elem *elem)
#ifdef RTE_MALLOC_ASAN
+/*
+ * ASAN_SHADOW_OFFSET should match to the corresponding
+ * value defined in gcc/libsanitizer/asan/asan_mapping.h
+ */
#ifdef RTE_ARCH_X86_64
#define ASAN_SHADOW_OFFSET 0x00007fff8000
+#elif defined(RTE_ARCH_ARM64)
+#define ASAN_SHADOW_OFFSET 0x001000000000
#endif
#define ASAN_SHADOW_GRAIN_SIZE 8
--
2.25.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3] eal/arm64: support ASan
2021-11-09 9:59 ` [dpdk-dev] [PATCH v3] " Volodymyr Fialko
@ 2021-11-12 13:34 ` David Marchand
0 siblings, 0 replies; 7+ messages in thread
From: David Marchand @ 2021-11-12 13:34 UTC (permalink / raw)
To: Volodymyr Fialko
Cc: dev, Bruce Richardson, Anatoly Burakov,
Jerin Jacob Kollanukkaran, Ruifeng Wang, Zhihong Peng
On Tue, Nov 9, 2021 at 11:00 AM Volodymyr Fialko <vfialko@marvell.com> wrote:
>
> This patch defines ASAN_SHADOW_OFFSET for arm64 according to the ASan
> documentation. This offset should cover all arm64 VMAs supported by
> ASan.
>
> Signed-off-by: Volodymyr Fialko <vfialko@marvell.com>
> Reviewed-by: David Marchand <david.marchand@redhat.com>
> Acked-by: Jerin Jacob <jerinj@marvell.com>
> Acked-by: Ruifeng Wang <ruifeng.wang@arm.com>
Applied, thanks.
--
David Marchand
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-11-12 13:34 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-08 13:45 [dpdk-dev] [PATCH] build: enable ASan for arm64 Volodymyr Fialko
2021-11-08 15:01 ` David Marchand
2021-11-08 16:37 ` Jerin Jacob
2021-11-08 22:45 ` [dpdk-dev] [PATCH v2] eal/arm64: support ASan Volodymyr Fialko
2021-11-09 5:39 ` Ruifeng Wang
2021-11-09 9:59 ` [dpdk-dev] [PATCH v3] " Volodymyr Fialko
2021-11-12 13:34 ` David Marchand
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).