build: enable ASan for arm64
PATCH 1/1 build: enable ASan for arm64
This patch defines ASAN_SHADOW_OFFSET for arm64 according to the ASan documentation. This offset should cover all arm64 VMAs supported by 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(-)
config/meson.build +1 -1
@@ -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
doc/guides/prog_guide/asan.rst +1 -1
@@ -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
lib/eal/common/malloc_elem.h +3 -0
@@ -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
Signature · 1 line
2.25.1
Quoted 30 lines · Volodymyr Fialko
This patch defines
ASAN_SHADOW_OFFSETfor arm64 according to the ASan documentation. This offset should cover all arm64 VMAs supported by ASan.Signed-off-by Volodymyr Fialko <[email protected]>--- 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(-)config/meson.build +1
-1@@ -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 endifdoc/guides/prog_guide/asan.rst +0
-0
doc/guides/prog_guide/asan.rst Example:: · line 36
Quoted 5 lines
doc/guides/prog_guide/asan.rst +1
-1@@ -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.
Quoted 8 lines
doc/guides/prog_guide/asan.rst +0
-0Other architectures may have to define ASAN_SHADOW_OFFSET. Example heap-buffer-overflow errorlib/eal/common/malloc_elem.h +0
-0
lib/eal/common/malloc_elem.h malloc_elem_cookies_ok(const struct malloc_elem *elem) · line 112
Quoted 6 lines
lib/eal/common/malloc_elem.h +3
-0@@ -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 u64kAArch64_ShadowOffset64 = 1ULL << 36;
libsanitizer/asan/asan_mapping.h:# define SHADOW_OFFSETkAArch64_ShadowOffset64
Quoted 6 lines
lib/eal/common/malloc_elem.h +0
-1#define ASAN_SHADOW_GRAIN_SIZE 8#define ASAN_MEM_FREE_FLAG 0xfd --2.25.1
I hope ppc will follow soon :-).
Signature · 1 line
David Marchand
Quoted 6 lines · Volodymyr Fialko
This patch defines
ASAN_SHADOW_OFFSETfor arm64 according to the ASan documentation. This offset should cover all arm64 VMAs supported by ASan.Signed-off-by Volodymyr Fialko <[email protected]>
++ Arm maintainers
Prefer to change the subject to eal/arm64: support ASan
Quoted 37 lines
--- 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(-)config/meson.build +1
-1@@ -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 endifdoc/guides/prog_guide/asan.rst +1
-1@@ -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 errorlib/eal/common/malloc_elem.h +0
-0
lib/eal/common/malloc_elem.h malloc_elem_cookies_ok(const struct malloc_elem *elem) · line 110
Quoted 4 lines
lib/eal/common/malloc_elem.h +1
-0@@ -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
lib/eal/common/malloc_elem.h malloc_elem_cookies_ok(const struct malloc_elem *elem) · line 111
Quoted 1 line
lib/eal/common/malloc_elem.h +1
-0+#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,
Quoted 9 lines
lib/eal/common/malloc_elem.h +1
-0+#endif #define
ASAN_SHADOW_GRAIN_SIZE8
#defineASAN_MEM_FREE_FLAG0xfd
--
2.25.1
PATCH v2 1/1 eal/arm64: support ASan
In reply to Volodymyr FialkoThis patch defines ASAN_SHADOW_OFFSET for arm64 according to the ASan documentation. This offset should cover all arm64 VMAs supported by ASan.
---
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(-)
config/meson.build +1 -1
@@ -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
doc/guides/prog_guide/asan.rst +1 -1
@@ -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
lib/eal/common/malloc_elem.h +2 -0
@@ -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
Signature · 1 line
2.25.1
Re: [dpdk-dev] [PATCH v2] eal/arm64: support ASan
Quoted 58 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Volodymyr Fialko
Sent: Tuesday, November 9, 2021 6:46 AM
To: [email protected]; Bruce Richardson <[email protected]>; Anatoly Burakov <[email protected]>
Cc: [email protected]; Volodymyr Fialko <[email protected]>; David Marchand <[email protected]>
Subject: [dpdk-dev] [PATCH v2] eal/arm64: support ASanThis patch defines
ASAN_SHADOW_OFFSETfor arm64 according to the ASan documentation. This offset should cover all arm64 VMAs supported by ASan.Signed-off-by Volodymyr Fialko <[email protected]>Reviewed-by David Marchand <[email protected]>Acked-by Jerin Jacob <[email protected]>---
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(-)config/meson.build index renamed from config/meson.build +0
-0
17b5bec406..7eb710c08d100644config/meson.build +0
-0@@ -428,7 +428,7 @@ if get_option('b_sanitize') == 'address' or
get_option('b_sanitize')== 'addressdpdk_extra_ldflags += '-lasan' endifconfig/meson.build +2
-1- 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(quoted diff) +0
-0
b/doc/guides/prog_guide/asan.rstindex6d1b871c93..28b2382fc7100644doc/guides/prog_guide/asan.rst +1
-1@@ -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 errorlib/eal/common/malloc_elem.h +0
-0
lib/eal/common/malloc_elem.h malloc_elem_cookies_ok(const struct malloc_elem · line 111
Quoted 6 lines
lib/eal/common/malloc_elem.h +2
-0@@ -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,
Quoted 5 lines
lib/eal/common/malloc_elem.h +0
-0#endif #define
ASAN_SHADOW_GRAIN_SIZE8
--
2.25.1
PATCH v3 1/1 eal/arm64: support ASan
In reply to Volodymyr FialkoThis patch defines ASAN_SHADOW_OFFSET for arm64 according to the ASan documentation. This offset should cover all arm64 VMAs supported by ASan.
---
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(-)
config/meson.build +1 -1
@@ -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
doc/guides/prog_guide/asan.rst +1 -1
@@ -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
lib/eal/common/malloc_elem.h +6 -0
@@ -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
Signature · 1 line
2.25.1
David Marchand
AppliedRe: [PATCH v3] eal/arm64: support ASan
Quoted 9 lines · Volodymyr Fialko
This patch defines
ASAN_SHADOW_OFFSETfor arm64 according to the ASan documentation. This offset should cover all arm64 VMAs supported by ASan.Signed-off-by Volodymyr Fialko <[email protected]>Reviewed-by David Marchand <[email protected]>Acked-by Jerin Jacob <[email protected]>Acked-by Ruifeng Wang <[email protected]>
Applied, thanks.
Signature · 1 line
David Marchand