DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Burakov, Anatoly" <anatoly.burakov@intel.com>
To: Olivier Matz <olivier.matz@6wind.com>, <zhihongx.peng@intel.com>
Cc: <konstantin.ananyev@intel.com>, <stephen@networkplumber.org>,
	<dev@dpdk.org>, <xueqin.lin@intel.com>
Subject: Re: [dpdk-dev] [PATCH v4 1/2] Enable ASan for memory detector on DPDK
Date: Mon, 27 Sep 2021 13:10:33 +0100	[thread overview]
Message-ID: <ca430ca6-4961-633c-3e72-3677dd5973d3@intel.com> (raw)
In-Reply-To: <YU2f4VwvT1XPAdFt@platinum>

On 24-Sep-21 10:52 AM, Olivier Matz wrote:
> Hi Zhihong,
> 
> On Fri, Sep 24, 2021 at 02:16:29AM +0000, zhihongx.peng@intel.com wrote:
>> From: Zhihong Peng <zhihongx.peng@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.
>> DPDK ASan function currently only supports on Linux x86_64.
>> Support other platforms, need to define ASAN_SHADOW_OFFSET value according
>> to google ASan document.
>>
>> 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": This is a non-essential option. When this option
>> is added, if a memory error occurs, ASan can clearly show where the
>> code is wrong.
>> "-Db_lundef=false": When use clang to compile DPDK, this option must
>> be added.
>>
>> Note:
>> a) The issue of ASan wild pointer is that dpdk ASan tool is not fully
>> adapted to google ASan. For example: Address 0x7fe2ffafa240 is a wild
>> pointer.
>> b) Centos needs to install libasan separately.
>> c) If the program uses DPDK cmdline, when a memory bug occurs, need
>> to execute the "stty echo" command.
>>
>> Signed-off-by: Xueqin Lin <xueqin.lin@intel.com>
>> Signed-off-by: Zhihong Peng <zhihongx.peng@intel.com>
> 
> Thank you for this patch, this looks quite useful.
> 
> Do you know what is the performance impact of enabling ASan?
> 
> Do you think a similar approach could be applied to mempools?

It would be a bit difficult, because mempools aren't actually allocating 
anything, they're just juggling pointers. A lot of times, an "allocated" 
mbuf wouldn't actually be allocated, and just sitting in the mempool 
cache, being "free" while still not present in the mempool.

Also, obviously, any such functionality (be it ASan for rte_malloc, or 
ASan for mempools) will necessarily only work inside one process, and 
will not support multiprocess.

> 
> Regards,
> Olivier
> 


-- 
Thanks,
Anatoly

  parent reply	other threads:[~2021-09-27 12:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-24  2:16 zhihongx.peng
2021-09-24  2:16 ` [dpdk-dev] [PATCH v4 2/2] lib/pipeline: Fix gcc compilation error using ASan zhihongx.peng
2021-09-24  9:52 ` [dpdk-dev] [PATCH v4 1/2] Enable ASan for memory detector on DPDK Olivier Matz
2021-09-24 15:13   ` Stephen Hemminger
2021-09-27 12:10   ` Burakov, Anatoly [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-09-18  7:41 [dpdk-dev] [PATCH v3] Enable AddressSanitizer feature " zhihongx.peng
2021-09-24  2:20 ` [dpdk-dev] [PATCH v4 1/2] Enable ASan for memory detector " zhihongx.peng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ca430ca6-4961-633c-3e72-3677dd5973d3@intel.com \
    --to=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    --cc=konstantin.ananyev@intel.com \
    --cc=olivier.matz@6wind.com \
    --cc=stephen@networkplumber.org \
    --cc=xueqin.lin@intel.com \
    --cc=zhihongx.peng@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).