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 D2BC0A0548; Fri, 24 Sep 2021 11:52:36 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 85DFF4122D; Fri, 24 Sep 2021 11:52:36 +0200 (CEST) Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) by mails.dpdk.org (Postfix) with ESMTP id 8C72040142 for ; Fri, 24 Sep 2021 11:52:34 +0200 (CEST) Received: by mail-wr1-f44.google.com with SMTP id r23so268207wra.6 for ; Fri, 24 Sep 2021 02:52:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=tYDm+5d67SCcC+9hdSpl4XjcPPm++rzuLCuJlz3IPNU=; b=T2jsClO25YNQcEzNjvaE2lctPvXJC8cuIoL5e0BZU9HgkDlOdJwvwHSMilltIKaeya fVE2vXp6LNH4qHx2stcYpwI9j6RIyaqUmE1PE/T7IMQ6c1zWtRP2bJusi26jkPgMLyYH KjkjmCvr4pj9C4V6zq6fb3s3m0t35zA5Mkh+zJMiaqranZ2P7llFrEg3vNxEbbK4mlhT Esfqz+X8wVZ+t0zFQju3loafF2iBCmYRc+CnUBvnEBjTjxIOR8s73L4DPmZ3HXzBzgh4 7B1ovKrocaJJ2QefTyZvtc3Bnpdes1ser76Yh8F1E/hjzBHZGHjAdiuCJ0NWHWDVMAjK a8Zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=tYDm+5d67SCcC+9hdSpl4XjcPPm++rzuLCuJlz3IPNU=; b=QpBcYQBL2pRBam6GCH0wBIVdE3B+Jy7w809+EoKrRNAzR/nPSkWkerLfll4NdcI6Yz fjQrLYEitv/cctyWVD90EbhGjdy3jxZXRJ8sQ8AV6Q/HFNHBCHStx8zbrTAqgojpubZq wE5Qv1TiVTImDpeUE1YEeNhk/V6E1nMPCI6yzJwBUVxn7C/ATBeIIUzqxqA5PNEeUTdu 4Z8MSRtx8Edcj7pfkEYubyNai4b4xYoJ3n5DDpetVV/JYirKxrjHj+uGq7sH5tyAvOpt lIOKBugbD9JUwaElmPVf5aUBZIx0IVtRag20XC8FD2PcoSq1Iwzxf2GHN78f5N1k0SqH kEWw== X-Gm-Message-State: AOAM530kYbnsxoFKOoPx+uIPm5ThckTtIsN4QvGdYRYZSnuY2uwssZzi sfB5DYDZVdoK3ZjyHIpld7KVmA== X-Google-Smtp-Source: ABdhPJy1hSYVdohCn0vu3bYa2mdI1HnwjCwGiWuwWVn91/6aEY9YEkOZ2VHxE7CkN+TVuX3ohTH27g== X-Received: by 2002:adf:b19e:: with SMTP id q30mr10123525wra.116.1632477154325; Fri, 24 Sep 2021 02:52:34 -0700 (PDT) Received: from 6wind.com ([2a01:e0a:5ac:6460:c065:401d:87eb:9b25]) by smtp.gmail.com with ESMTPSA id f19sm7760855wmf.11.2021.09.24.02.52.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 02:52:33 -0700 (PDT) Date: Fri, 24 Sep 2021 11:52:33 +0200 From: Olivier Matz To: zhihongx.peng@intel.com Cc: anatoly.burakov@intel.com, konstantin.ananyev@intel.com, stephen@networkplumber.org, dev@dpdk.org, xueqin.lin@intel.com Message-ID: References: <20210924021630.1291343-1-zhihongx.peng@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210924021630.1291343-1-zhihongx.peng@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" 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? Regards, Olivier