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 CC41BA0C40; Fri, 11 Jun 2021 08:15:11 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 48BFA4067C; Fri, 11 Jun 2021 08:15:11 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mails.dpdk.org (Postfix) with ESMTP id E5F334014F for ; Fri, 11 Jun 2021 08:15:09 +0200 (CEST) IronPort-SDR: UaDQpnTQ6q9bxIhxpZoUd0EzSc+M8pbGBfU+qpvm0K/endr3ftyHSYt9TXOtGWBXoJc0AN3cOi PTTOxiWPLS7w== X-IronPort-AV: E=McAfee;i="6200,9189,10011"; a="203635275" X-IronPort-AV: E=Sophos;i="5.83,265,1616482800"; d="scan'208";a="203635275" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2021 23:15:07 -0700 IronPort-SDR: lGbIjs4gVWiREJQgsL1JJBkOmB/OtqXdyYdmXp1YoXSEFgLjkrqmh/Pb/bbqa1l9n9lNJrJeDH gyZnMTc0vuhg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,265,1616482800"; d="scan'208";a="441469622" Received: from fmsmsx605.amr.corp.intel.com ([10.18.126.85]) by orsmga007.jf.intel.com with ESMTP; 10 Jun 2021 23:15:07 -0700 Received: from fmsmsx602.amr.corp.intel.com (10.18.126.82) by fmsmsx605.amr.corp.intel.com (10.18.126.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Thu, 10 Jun 2021 23:15:07 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4 via Frontend Transport; Thu, 10 Jun 2021 23:15:07 -0700 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (104.47.56.172) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2242.4; Thu, 10 Jun 2021 23:15:07 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CKd7P5roqyy5eRt5TR9CK89JPdWa7k6Rj2gZJi5CvdZN7r49l1LlQifrp+ur+t9eZdQIyTkO5GXU4qWx/EQ6tCJ6x+bhCdD+22Qq5kM7VVPpmCkXMu/MjlusYEp/H/ESvEYiz0ORoY1DFNx6ABZIF2ST25CgIbEPLcQIiVw0laE5FtEbftxMUSNkMwWDxwWl5ZUFxvX9w69/9TvF5njuB2wbb3eYx7/w5kquPdWr9ShRz5pIRSysQYXPqMxKO+vI79gX7RHYp0zce5Mfu3ZLJKDkcql7FBky6uE8LqoLbW9A29MmlYYX1hz1CeiOByRDCCVGf+4kLnFt9pWvVvY4lQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Lys7qIUK7qp2VwIUE+IBm54BcNnEwR0wsmTVTUtxVzI=; b=M25hbiILte6sMJkul7NAt+lZlBc7H2fKAJ62BXV4y6/VOCCb/qe8b1tjMk5MzsqcrzUBkP6aIhy6SfI519bGsiQXeclPjtWzV6QCn0sHFI5vWLNqWYF0riVnDe7tizxxFmvjpJE6/MKu54cw4GXwK0ZSralaWo1vXlZH2jy5RpNLN7PfJVgeDudgsqx6YU8Y4IpAzdMky5aSWaT82GrsUqEtLMggScTQqYcinPypcV8ceRPtwHXQwueOyGz6MbOYWGA18tBw2XAflPD28rYXGxmZEhU+vcqPSdgZ5L44WF20zGIJ57+ygQ+S+GycSBQsnbBtRhiPd9gSzPmntJwj8g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Lys7qIUK7qp2VwIUE+IBm54BcNnEwR0wsmTVTUtxVzI=; b=PMbpbRAwQ4fQGPKdTtaYbRiutgevgVcH+dfPhK/GVlhU/Kh2Xypy/nRMGESwXRdQ85YwP/dz3RAjK4ySRlGHbNsrLdkOoSMbAlI+qftTBtYh/1IdcRnZqv9t8jbS679YOfW5rzn20KekDiOFGLdrqKa96upQ0lHBhXGcsE/pxXc= Received: from BN7PR11MB2658.namprd11.prod.outlook.com (2603:10b6:406:ae::16) by BN6PR11MB4002.namprd11.prod.outlook.com (2603:10b6:405:76::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.20; Fri, 11 Jun 2021 06:15:05 +0000 Received: from BN7PR11MB2658.namprd11.prod.outlook.com ([fe80::152:a489:e4ab:faf3]) by BN7PR11MB2658.namprd11.prod.outlook.com ([fe80::152:a489:e4ab:faf3%5]) with mapi id 15.20.4219.024; Fri, 11 Jun 2021 06:15:05 +0000 From: "Lin, Xueqin" To: Stephen Hemminger , "Peng, ZhihongX" CC: "Burakov, Anatoly" , "dev@dpdk.org" Thread-Topic: [RFC] porting AddressSanitizer feature to DPDK Thread-Index: AQHXXbgLxn7WkPyP3E6D8H20N7Dp+6sNq9aAgACe7BA= Date: Fri, 11 Jun 2021 06:15:05 +0000 Message-ID: References: <20210610051352.48493-1-zhihongx.peng@intel.com> <20210610130311.57f5dbfb@hermes.local> In-Reply-To: <20210610130311.57f5dbfb@hermes.local> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-version: 11.5.1.3 dlp-reaction: no-action dlp-product: dlpe-windows authentication-results: networkplumber.org; dkim=none (message not signed) header.d=none;networkplumber.org; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.102.204.51] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 6d4c8510-d844-4e93-3295-08d92ca04158 x-ms-traffictypediagnostic: BN6PR11MB4002: x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6790; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: xY6Mvhmb6Vs38tBMFkYGrxd6gysdqPuDABJgB4Q7Mmt7TCESt1WJwCmam/Mkn2kI7tMM5/yYQkcCF/U6GQg3EWW5rfeUuqUGbQfxp+XDQvUI5tYxTlClwJHOnjZt+5WMCDucEB2JTew2owY+e195TUuFK1o9cUWBKBAQcimT6ykeLRI+bhThyGY1taclJPV9gxJggNeutLCRcz+QUpmrrd6zRRPSOKbQShA2KgqZCMk38nkp6aHcQSAIKBn7CqivvlgItavqnQFLWdlEVyhQGO+5hplaiOJpWSlpjdWG694iH8BX9tHC4aSuebbucfKoabahul6NGqBBNEKGqzZFtTFGFW+m6SVHzYhQrW/I0NP8rNnVH0Rn7LF9xhvDgqAmm7GC+KmEHCmMC+narmAH8SdvjvqwVlWDVZXqXHatYhkLWIhQCSDJboOLg1OV+Vorgh1MSTZCW7moH8ag/7ejiLOYdrdbymbdYUJLr4IL3QoTOzdEB01EeV7A9w073ztOsPXb/8z5jsCvbAUwKfrVJPMVqfrnQ2CkS3Vs0FZvysDx+7iE3wtXm4jrBpg6A8dxHlDCW5Kn2q9f475QFOEGqduUIb6oY0OhOfflbKoy7qc911buaZotgO+eBrZZGdVvc/3M8+ZT1dWwbVSK9tYNdxjHsbPtpxlN7u+7JfP9VsrPDResxOwZZJFR3XGmLCoVn+dlWlZgTOKuWY7a9xYaDegIwlIHqszzIEni28eT5gVWF2bfc5ub/iL3f5pZ5c1i3CDLP4oRWS5KLH5Q2WkIOw== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BN7PR11MB2658.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(136003)(376002)(346002)(366004)(396003)(71200400001)(122000001)(9686003)(6506007)(186003)(33656002)(5660300002)(53546011)(83380400001)(4326008)(38100700002)(8676002)(8936002)(26005)(2906002)(7696005)(64756008)(76116006)(66476007)(54906003)(66446008)(52536014)(478600001)(66946007)(316002)(110136005)(6636002)(86362001)(66556008)(55016002)(49343001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?+4OtfDsWs5IgeUiYpZSk1qmD4/2BS856ECF+YpDMFv0LRSx69Ku1VDqvU6bk?= =?us-ascii?Q?LQFG7HyyhdGaQ3kvBwHW1g2qJnKyxwZ7ElqeXY0IjhUcHiGpKDHRw/PFODP7?= =?us-ascii?Q?dWxN9C/R44l68R8rw3ftxt/xKaAAOTz89+UwRjbxWSQzoOnLLVzng6wiEK5f?= =?us-ascii?Q?kAfgPaLTpz7byKw9RXF23C4tc42zYGBCsvwx1oq7siQw5Hwu/r0A8Yrd2nkv?= =?us-ascii?Q?9kg2bTnw4Z0J9WgVIIJ/Y5as/PvVSmsZgXJiMZNUNRZQ5GtUVXha/JzaT47N?= =?us-ascii?Q?h8qqRTg7LR8v40zr1Z3DiCaG8/2Pwk3uUEgIMIeX/47fqmvsURAZD+kzOpP/?= =?us-ascii?Q?1QF3X8K9XG3vzY3uj9/0mMqUNPG3LvMxaNEen1KNhLfKg1Qp6DpPUYzsKYh/?= =?us-ascii?Q?BHso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dx9/4oj6oHe4MIk?= =?us-ascii?Q?GkblBfYsSSAPPRg0gsN+QAPS?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BN7PR11MB2658.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6d4c8510-d844-4e93-3295-08d92ca04158 X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Jun 2021 06:15:05.0475 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: +a++/IRlHotc9VE7S6vB8L6M+6yFYFOO3f9DPoQ1Y2IXUu8MeS3b/D4mf0YRBtuE2KPGasbON+T6jEJ2+2kh0w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR11MB4002 X-OriginatorOrg: 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" > -----Original Message----- > From: Stephen Hemminger > Sent: Friday, June 11, 2021 4:03 AM > To: Peng, ZhihongX > Cc: Burakov, Anatoly ; dev@dpdk.org; Lin, > Xueqin > Subject: Re: [RFC] porting AddressSanitizer feature to DPDK >=20 > On Thu, 10 Jun 2021 13:13:52 +0800 > zhihongx.peng@intel.com wrote: >=20 > > 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 =3D rte_zmalloc(NULL, 7, 0); > > p[7] =3D 'a'; > > ...... > > > > Here is an example of use-after-free bug: > > ...... > > char *p =3D rte_zmalloc(NULL, 7, 0); > > rte_free(p); > > *p =3D 'a'; > > ...... > > > > If you want to use this feature, > > you need to use the following compilation options: > > -Dc_args=3D'-DRTE_MALLOC_ASAN' > > -Db_lundef=3Dfalse -Db_sanitize=3Daddress > > > > Signed-off-by: Xueqin Lin > > Signed-off-by: Zhihong Peng > > --- > > lib/eal/common/malloc_elem.c | 33 +++++++- > > lib/eal/common/malloc_elem.h | 141 > ++++++++++++++++++++++++++++++++++- > > lib/eal/common/malloc_heap.c | 19 +++++ > > lib/eal/common/rte_malloc.c | 6 ++ > > 4 files changed, 197 insertions(+), 2 deletions(-) > > > > diff --git a/lib/eal/common/malloc_elem.c > > b/lib/eal/common/malloc_elem.c index c2c9461f1..4a146b1b9 100644 > > --- a/lib/eal/common/malloc_elem.c > > +++ b/lib/eal/common/malloc_elem.c > > @@ -446,6 +446,9 @@ malloc_elem_alloc(struct malloc_elem *elem, > size_t size, unsigned align, > > struct malloc_elem *new_free_elem =3D > > RTE_PTR_ADD(new_elem, size + > MALLOC_ELEM_OVERHEAD); > > > > +#ifdef RTE_MALLOC_ASAN > > + asan_clear_split_alloczone(new_free_elem); > > +#endif >=20 >=20 > Two things: > ASAN should be detected using standard compiler flags, not a DPDK option. > GCC uses __SANITIZE_ADDRESS__ and Clang uses feature macro. Thanks Stephen for your review and suggestion, we will improve this part. Only use Asan standard compiler flags, remove DPDK option for the tool dete= ct. =20 >=20 > Rather than littering DPDK code with ifdefs' a better method is to do def= ine > stub inline (or macros if you insist) in the header file. Good capture, we will improve it in V2. >=20