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

David Christensen drc at linux.vnet.ibm.com
Mon Sep 20 21:41:25 CEST 2021



On 9/18/21 12:21 AM, Peng, ZhihongX wrote:
>> -----Original Message-----
>> From: David Christensen <drc at linux.vnet.ibm.com>
>> Sent: Saturday, September 18, 2021 4:51 AM
>> To: Peng, ZhihongX <zhihongx.peng at intel.com>; Burakov, Anatoly
>> <anatoly.burakov at intel.com>; Ananyev, Konstantin
>> <konstantin.ananyev at intel.com>; stephen at networkplumber.org
>> Cc: dev at dpdk.org; Lin, Xueqin <xueqin.lin at intel.com>
>> Subject: Re: [dpdk-dev] [PATCH] Enable AddressSanitizer feature on DPDK
>>
>>>>> 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
>>>
>>> We do not have a ppc platform, so there is no adaptation.
>>> doc/guides/prog_guide/asan.rst has stated that we currently only
>>> support Linux x86_64. You can adapt according to the following documents,
>> the main work is to modify the base address according to the platform.
>>> Documents:
>>> https://github.com/google/sanitizers/wiki/AddressSanitizer
>>> https://github.com/llvm/llvm-project/tree/main/compiler-rt
>>
>> Understand you don't have such a platform.  I looked into it and suggest the
>> following change in lib/eal/common/malloc_elem.h:
>>
>> #define ASAN_SHADOW_GRAIN_SIZE  8
>> #define ASAN_SHADOW_SCALE       3
>> #ifdef RTE_ARCH_PPC_64
>> #define ASAN_SHADOW_OFFSET 0x020000000000 #else #define
>> ASAN_SHADOW_OFFSET 0x00007fff8000 #endif
>> #define ASAN_MEM_FREE_FLAG      0xfd
>> #define ASAN_MEM_REDZONE_FLAG   0xfa
>> #define ASAN_MEM_TO_SHADOW(mem) (((mem) >>
>> ASAN_SHADOW_SCALE) +
>> ASAN_SHADOW_OFFSET)
>>
>>
>> This resolves the segmentation error I receive.
>>
>> Dave
>>
> 
> Great, good information for dpdk asan tool. Because we can't do many tests,
> so when this patch is merged into the main line, you can submit the ppc
> architecture patch.

If your argument is that this is x86 only then please ensure it can't be 
enabled on non-x86 platforms such as ARM and PPC.  I can then easily 
submit a follow-on patch to enable for PPC.

As the patch currently stands it enables ASAN on a non-tested platform 
and provides an unexpected error for some users when it can easily be 
avoided.  I'd advise not accepting the patch as currently presented.

Dave


More information about the dev mailing list