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 B6DACA0548; Mon, 27 Sep 2021 14:10:49 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A7551410DA; Mon, 27 Sep 2021 14:10:49 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id 4E3F740E3C for ; Mon, 27 Sep 2021 14:10:48 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10119"; a="203953794" X-IronPort-AV: E=Sophos;i="5.85,326,1624345200"; d="scan'208";a="203953794" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Sep 2021 05:10:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,326,1624345200"; d="scan'208";a="456230533" Received: from fmsmsx606.amr.corp.intel.com ([10.18.126.86]) by orsmga002.jf.intel.com with ESMTP; 27 Sep 2021 05:10:42 -0700 Received: from fmsmsx607.amr.corp.intel.com (10.18.126.87) by fmsmsx606.amr.corp.intel.com (10.18.126.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12; Mon, 27 Sep 2021 05:10:41 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx607.amr.corp.intel.com (10.18.126.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12; Mon, 27 Sep 2021 05:10:41 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12 via Frontend Transport; Mon, 27 Sep 2021 05:10:41 -0700 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.109) 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.12; Mon, 27 Sep 2021 05:10:40 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H8fiG5gSf+g+J0jneSUXXVjkGOud2Y86ggvisa9J/g63xlZoMDm+Y8gLcCzv91MAzj0FkLYPqHXvroLKRLsKSGDcqnFnVcGTxJlvwtQxyVFWmMmcR5NPOEhAWN3GI7Ob5q87ClBkZRadAIlo3qOBhLVyead4uw/b1EXbayTIOdc9NgnZXf+90iZjkW54aFXSyhZVucNRfPpEk6NyCn6bcmY+ht6tge6K69jns5ONuepZ4pgVc+qmbUX4OvFdiWO62wU4/EZ1e0mjAjxjLuACeCnHk2ebu1U9xunMxNnxkCw46wDNU1ofIZHNShWIarSX6NPOMssekyTFtE44wZtAOQ== 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; bh=S0/2f/Z4tVtrrxV0vipETGoaBJpb3Bbspv+o5mjWEv0=; b=bsFYodLAg/BTS5hOJWdHQcaEU3gKttTiwOXdGRs7qO3NVOolDO8j571L6dN4iXw0p8i1avXDs07QCfNS948Y3lvnZXv6JGU0VFcZ86qbTD7Ow2nj6MfSB4aC1BLMLBvkL4gLhjFMc5CPUVECxblW5RaUi5yyEbpg4l0y9vLLji8IaL2+5EugBrYG+uXZhHhfFn+XOwMDa1fxx/ONxYtHJ/AXqxWXUcEosoxrjbG9sLELLKVOjo1RDj5ynyXkm6QN0xKRXRwpnBzJCRpxscvHR5M0RKlBYTDI8Zsa7rZipiiZzCNSx7O3ggvriglSzN0jRxeYg53lh/cvh/IkGssT/A== 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=S0/2f/Z4tVtrrxV0vipETGoaBJpb3Bbspv+o5mjWEv0=; b=bH8AlNwZKuB7JgoZJrGIIj2DQ3tam7fWpmWfxiNOFFxnOoRaGrAPczEjd8RcKhQoE09iBxKro4fF/Xm/HvuCctix7L6r8IsjXgwgorAkIXH0pImcabQio200uN5v7X3VpYs4nXaHUHVAAM7zTPePZW8ZRsRooVtN9uxvGv2lc2M= Authentication-Results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=intel.com; Received: from PH0PR11MB5093.namprd11.prod.outlook.com (2603:10b6:510:3e::23) by PH0PR11MB4904.namprd11.prod.outlook.com (2603:10b6:510:40::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.14; Mon, 27 Sep 2021 12:10:39 +0000 Received: from PH0PR11MB5093.namprd11.prod.outlook.com ([fe80::d145:710a:1bac:7e91]) by PH0PR11MB5093.namprd11.prod.outlook.com ([fe80::d145:710a:1bac:7e91%9]) with mapi id 15.20.4544.021; Mon, 27 Sep 2021 12:10:39 +0000 To: Olivier Matz , CC: , , , References: <20210924021630.1291343-1-zhihongx.peng@intel.com> From: "Burakov, Anatoly" Message-ID: Date: Mon, 27 Sep 2021 13:10:33 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0 Thunderbird/78.14.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-ClientProxiedBy: DB6PR07CA0087.eurprd07.prod.outlook.com (2603:10a6:6:2b::25) To PH0PR11MB5093.namprd11.prod.outlook.com (2603:10b6:510:3e::23) MIME-Version: 1.0 Received: from [192.168.1.10] (212.17.34.161) by DB6PR07CA0087.eurprd07.prod.outlook.com (2603:10a6:6:2b::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.8 via Frontend Transport; Mon, 27 Sep 2021 12:10:38 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: abf486ab-d76b-4028-94ce-08d981afd213 X-MS-TrafficTypeDiagnostic: PH0PR11MB4904: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: J38LvJ8CfyiW5x8KbMKWzCnRKHOYTHUDRlc4MVhxvJ1Ak7mMnUo20t9AX3sN2R7mYboPa4HC3wp6xtyCWs2AkU9xiu5n1M291Icct4e2OMK6/npC9c+7+FeoWTs/Ri1Q7CodrLcRbPDPn/dNN9WScZZtlDy0VXLzcNLve2PQCCE+u9jDiOlvPB88h3FCCySZfWhyWJjbcX9NQOA1y8RIu25Fs/t6F7tyvEAqQWXY3R3gMRoYUUPoalPsVW/91cBPOvoawZsrhb/h3R5KnbvEuqtsw6NEDUA+rn3YXC7j9lfJEzwEroI3+mRMG9Jo3Nw2LyzDtZ5HhAWcXe4oTMH62yQm7gguqGjVrERhPRwaA5NON+aAN34IABoAq9uZZjgDbj1dhLjDSQ1gGAPPadhEg216DXQvgdIJddDSZx+kTk7vmcp/K44kuovCG0e0/TIMa3OlXRC4mzs/jbsKBVXmXk09JuYdkUY879yWggYqvXOQsW74hV3TwKgvaM0TwaftJxjMvL9p8MpM3bC04KgdDhUlwvRgIvqBPrnX8l7xjMA8V+IWcva+pJbmmlT/GYqb5MfdmbPd1lN/4IZSPY1p5NeD2wUf6XFA6ROHqZeft7S2FSqyyo2SjiBoDKl4EJ+VQOSbtU9/OrePVboUX2zftgqoMGTpXRk/Mv4GQ2NLo8EIpnbJEWLnYFZvFBnqXbepyRsEkzP/VrlhdxoslMkecJEYZq+hUgTlcRaEsis6iOEdUiC6F2DgiZObYfzCP+k8R8M0Cwr9zAxu0Z46RtWojiZwWCNtDdqGRnSBuEu4ISwETuaUtl0rlsz6tgh/jxiaSypinC0CcqyYOw1Ikvrzuw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR11MB5093.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(16576012)(6636002)(66946007)(2616005)(31686004)(316002)(107886003)(4326008)(5660300002)(2906002)(36756003)(66476007)(956004)(66556008)(508600001)(8676002)(83380400001)(26005)(31696002)(8936002)(6666004)(86362001)(186003)(53546011)(6486002)(38100700002)(45980500001)(43740500002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?QU1kZzRTalRBRnNWK0tvUHVrUTg2SnVQeUZqM2tiWG8vWWhGMEFUMlU4WWt5?= =?utf-8?B?eFVlTVVhTkZUbzI5T1Z3NzQ2dzg0WnJZd0lGRU1SakdQT2poaXVtRllxK2FJ?= =?utf-8?B?OE0vMnVsNG5IckkzZjQ3R0htQWZqRXZ2R1k0TTZ4elVjUndYbkE3N3Mya0tC?= =?utf-8?B?NDVuaTkxYVppNmVQNVZjWkkxcTZrWTJGbnQ1UFQ4dVcwSFN2STU0SHdCK3hE?= =?utf-8?B?dEE5MTI4WnQyWld1a1UxWDF2cWl1S1A2Ym0wajJSRDFtMGVOa3FqN0pBOXd2?= =?utf-8?B?L0N0RjJqeW9qb0k0d0hnZ0RCQW5xTnFHTWg4eHJP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uUlNqbCtVME1SOHFhK0tGL2tnNWo5TFZnU1Q2?= =?utf-8?B?MHJETW9paU1FTEJEOCtlekJLZEdaNXYrOTlhc1FpUnpUZWZ1cVd6bFpUMVNm?= =?utf-8?B?cEdrajc2Q3lWdTBXcGtFdUE0Ymx3eGpONVd6RWRISW15bmt1SmZsVEpVTTBs?= =?utf-8?B?SWtBUzJ1VUVMQ2QwTTdhR0NxbStUc291dVFURmtxVUZobUVlWG1BeWZXb3cx?= =?utf-8?B?WVhVNlNON2NjRnV1a3lTUjhtNlZmWDZ1NG41QUFlemlwUk1GT1FnZVhiRk9P?= =?utf-8?B?S1owdmgzTVFxT1doaEJPY2pwTUtzKzhzd0JEVGkzVGF6YUVkTndWODVWbzhY?= =?utf-8?B?RVNlTDVUMkVtbkwwcjlYSmJlcTYrZVBSaFB6QVFlTEdmdGVNb2dUa2JuOG91?= =?utf-8?B?bVMzb0xjSlI4U2NxQXRIZWx3SnBEVnlaUzBxUzBVdnlHbjU5VUxGR1NmU2lo?= =?utf-8?B?YUhSMEtWZkkrZjU1YTcxTTJPMmJ0RURaOTVLYUcyS3hyd0g2MVJsM3RTVnBV?= =?utf-8?Q?vsLal4JKayDzRfst9AzDZGS0wFh93IcNupZhM5w?= X-MS-Exchange-CrossTenant-Network-Message-Id: abf486ab-d76b-4028-94ce-08d981afd213 X-MS-Exchange-CrossTenant-AuthSource: PH0PR11MB5093.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2021 12:10:39.4648 (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: cj7Tqv1mlFagiEXJa7suwiQ4SoNN8TWg6NrbAkHXBVXkp8Q3x1y9/3NicZf1iIaJBj1WGfO4BDXCK6IkLY97rTTwfJcez+Y98kiq6gHxBYA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR11MB4904 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH v4 1/2] Enable ASan for memory detector on 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 24-Sep-21 10:52 AM, Olivier Matz wrote: > Hi Zhihong, > > On Fri, Sep 24, 2021 at 02:16:29AM +0000, 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), >> 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 >> Signed-off-by: Zhihong Peng > > 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? It would be a bit difficult, because mempools aren't actually allocating anything, they're just juggling pointers. A lot of times, an "allocated" mbuf wouldn't actually be allocated, and just sitting in the mempool cache, being "free" while still not present in the mempool. Also, obviously, any such functionality (be it ASan for rte_malloc, or ASan for mempools) will necessarily only work inside one process, and will not support multiprocess. > > Regards, > Olivier > -- Thanks, Anatoly