From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 92F41A0C4E; Thu, 10 Jun 2021 10:33:04 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 246E14067C; Thu, 10 Jun 2021 10:33:04 +0200 (CEST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id 1FB4B4003C for ; Thu, 10 Jun 2021 10:33:02 +0200 (CEST) IronPort-SDR: wRFItNmPJVnGaYtWGCOwIG9VXdomac+p1awPpWUSvR1Yc4HZbEGgBAczTPkUoiXnBFLcn0Ehwp p698Jnj+PzIw== X-IronPort-AV: E=McAfee;i="6200,9189,10010"; a="266407612" X-IronPort-AV: E=Sophos;i="5.83,263,1616482800"; d="scan'208";a="266407612" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2021 01:32:54 -0700 IronPort-SDR: j0kV2yrbqRCBNnw4iJ+ok9auPczOeLa+d2y5DBj/UDJTKN99dewAWPCRZlAUGs+tz4Da9aXL3J c279oXgg3utA== X-IronPort-AV: E=Sophos;i="5.83,263,1616482800"; d="scan'208";a="419622629" Received: from bricha3-mobl.ger.corp.intel.com ([10.252.28.139]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-SHA; 10 Jun 2021 01:32:52 -0700 Date: Thu, 10 Jun 2021 09:32:48 +0100 From: Bruce Richardson To: zhihongx.peng@intel.com Cc: anatoly.burakov@intel.com, stephen@networkplumber.org, dev@dpdk.org, xueqin.lin@intel.com Message-ID: References: <20210610051352.48493-1-zhihongx.peng@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210610051352.48493-1-zhihongx.peng@intel.com> Subject: Re: [dpdk-dev] [RFC] porting AddressSanitizer feature to DPDK X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Thu, Jun 10, 2021 at 01:13:52PM +0800, zhihongx.peng@intel.com wrote: > From: Zhihong Peng > > 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=address > Rather 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