[dpdk-dev] [PATCH] Enable AddressSanitizer feature on DPDK

David Christensen drc at linux.vnet.ibm.com
Fri Sep 10 19:58:43 CEST 2021


> From: Zhihong Peng <zhihongx.peng at intel.com>
> 
> AddressSanitizer (ASan) is a google memory error detect
> standard tool. It could help to detect use-after-free and
> {heap,stack,global}-buffer overflow bugs in C/C++ programs,
> print detailed error information when error happens, large
> improve debug efficiency.
> 
> By referring to its implementation algorithm
> (https://github.com/google/sanitizers/wiki/AddressSanitizerAlgorithm),
> enable heap-buffer-overflow and use-after-free functions on dpdk.
> 
> Here is an example of heap-buffer-overflow bug:
> 	......
>          char *p = rte_zmalloc(NULL, 7, 0);
>          p[7] = 'a';
> 	......
> 
> Here is an example of use-after-free bug:
> 	......
>          char *p = rte_zmalloc(NULL, 7, 0);
>          rte_free(p);
>          *p = 'a';
> 	......
> 
> If you want to use this feature,
> you need to add below compilation options when compiling code:
> -Dbuildtype=debug -Db_lundef=false -Db_sanitize=address
> "-Dbuildtype=debug": Display code information when coredump occurs
> in the program.
> "-Db_lundef=false": It is enabled by default, and needs to be
> disabled when using asan.

On initial inspection, it appears ASAN functionality doesn't work with 
DPDK on PPC architecture.  I tested the patch with several compiler 
versions (gcc 8.3.1 from RHEL 8.3 through gcc 11.2.1 from the IBM 
Advanced Toolchain 15.0) and observed the following error when running 
testpmd with ASAN enabled:

AddressSanitizer:DEADLYSIGNAL
=================================================================
==49246==ERROR: AddressSanitizer: SEGV on unknown address 0x0000a0077bd0 
(pc 0x000010b4eca4 bp 0x7fffffffe150 sp 0x7fffffffe150 T0)
==49246==The signal is caused by a UNKNOWN memory access.
     #0 0x10b4eca4 in asan_set_shadow ../lib/eal/common/malloc_elem.h:120
     #1 0x10b4ed68 in asan_set_zone ../lib/eal/common/malloc_elem.h:135
     #2 0x10b4ee90 in asan_clear_split_alloczone 
../lib/eal/common/malloc_elem.h:162
     #3 0x10b51f84 in malloc_elem_alloc ../lib/eal/common/malloc_elem.c:477
...

Can you incorporate an exception for PPC architecture with this patch 
while I look into the problem further?

Dave


More information about the dev mailing list