All of lore.kernel.org
 help / color / mirror / Atom feed
From: Olivier Matz <olivier.matz@6wind.com>
To: zhihongx.peng@intel.com
Cc: anatoly.burakov@intel.com, 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: Fri, 24 Sep 2021 11:52:33 +0200	[thread overview]
Message-ID: <YU2f4VwvT1XPAdFt@platinum> (raw)
In-Reply-To: <20210924021630.1291343-1-zhihongx.peng@intel.com>

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?

Regards,
Olivier

  parent reply	other threads:[~2021-09-24  9:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-24  2:16 [dpdk-dev] [PATCH v4 1/2] Enable ASan for memory detector on DPDK 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 ` Olivier Matz [this message]
2021-09-24 15:13   ` [dpdk-dev] [PATCH v4 1/2] Enable ASan for memory detector on DPDK Stephen Hemminger
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=YU2f4VwvT1XPAdFt@platinum \
    --to=olivier.matz@6wind.com \
    --cc=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    --cc=konstantin.ananyev@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.