From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D30FCC47094 for ; Thu, 10 Jun 2021 08:33:05 +0000 (UTC) Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by mail.kernel.org (Postfix) with ESMTP id 32A91613B3 for ; Thu, 10 Jun 2021 08:33:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 32A91613B3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dev-bounces@dpdk.org 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