Re: [dpdk-dev] [RFC] porting AddressSanitizer feature to DPDK
From: Bruce Richardson <hidden>
Date: 2021-06-10 08:33:05
On Thu, Jun 10, 2021 at 01:13:52PM +0800, zhihongx.peng@intel.com wrote:
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),
ported heap-buffer-overflow and use-after-freefunctions to 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 use the following compilation options:
-Dc_args='-DRTE_MALLOC_ASAN'
-Db_lundef=false -Db_sanitize=addressRather than forcing the user to pass in the extra c_args, you can
automatically add it from the eal/meson.build files. Something like:
if get_option('b_sanitize').startswith('address'):
cflags += '-DRTE_MALLOC_ASAN'
endif
/Bruce