DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Olivier Matz <olivier.matz@6wind.com>
Cc: zhihongx.peng@intel.com, anatoly.burakov@intel.com,
	konstantin.ananyev@intel.com, dev@dpdk.org, xueqin.lin@intel.com
Subject: Re: [dpdk-dev] [PATCH v4 1/2] Enable ASan for memory detector on DPDK
Date: Fri, 24 Sep 2021 08:13:52 -0700	[thread overview]
Message-ID: <20210924081352.5f587f2a@hermes.local> (raw)
In-Reply-To: <YU2f4VwvT1XPAdFt@platinum>

On Fri, 24 Sep 2021 11:52:33 +0200
Olivier Matz <olivier.matz@6wind.com> 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?

Purely application dependent. In the Linux kernel on x86 it is around
10% according to report by Google. My observation is that for DPDK
(for malloc/free etc, not this patch) ASAN causes large impact
on Arm like 90% slower. But our application is CPU intensive.
 
> Do you think a similar approach could be applied to mempools?

  reply	other threads:[~2021-09-24 15:13 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 [this message]
2021-09-27 12:10   ` Burakov, Anatoly
  -- 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=20210924081352.5f587f2a@hermes.local \
    --to=stephen@networkplumber.org \
    --cc=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    --cc=konstantin.ananyev@intel.com \
    --cc=olivier.matz@6wind.com \
    --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).