Re: [dpdk-dev] [PATCH] Enable AddressSanitizer feature on DPDK
From: Peng, ZhihongX <hidden>
Date: 2021-09-13 05:36:04
-----Original Message----- From: David Christensen <redacted> Sent: Saturday, September 11, 2021 1:59 AM To: Peng, ZhihongX <redacted>; Burakov, Anatoly [off-list ref]; Ananyev, Konstantin [off-list ref]; stephen@networkplumber.org Cc: dev@dpdk.org; Lin, Xueqin <redacted> Subject: Re: [dpdk-dev] [PATCH] Enable AddressSanitizer feature on DPDKquoted
From: Zhihong Peng <redacted> 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
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