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 0134FA0C43; Thu, 30 Sep 2021 20:49:48 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 701FC40DDA; Thu, 30 Sep 2021 20:49:48 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id B3B9A4067E for ; Thu, 30 Sep 2021 20:49:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633027786; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=9+Vv1d84qXzU1lVQiu5KN/8TYmuMNG85dejnqUQnuiY=; b=g6cP/GmmFV3wq4g/Q3M01nZ0ubBZvUKe6iO82plnqQkqmwdXUJk5qFtaLH4UW+j1uNCmCi q60RBjSk2g2zn/cVlV2gaidodddFHjppTCrABc9AsB+UaixaHj9EztYNDBqx/8D+7CB8gU Kt/UuyQenPQCdRj2vylOAv9SjCpn/OA= Received: from mail-lf1-f72.google.com (mail-lf1-f72.google.com [209.85.167.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-296-wOOZSEcbPPGDJZGNwuF4Xg-1; Thu, 30 Sep 2021 14:49:44 -0400 X-MC-Unique: wOOZSEcbPPGDJZGNwuF4Xg-1 Received: by mail-lf1-f72.google.com with SMTP id r14-20020ac25c0e000000b003fc149ed50eso6587127lfp.11 for ; Thu, 30 Sep 2021 11:49:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=9+Vv1d84qXzU1lVQiu5KN/8TYmuMNG85dejnqUQnuiY=; b=KmFVsQFMcMea4pQDIfVT0DMtX05fEgOKpDTbpxcHcoFEnMLUOwTcwDZdMqDd2yXHKI BIu6B7diEp0RJINdZzPO42iM6yhLV1dm1AY1xBxjo+j1tgP+K8F2J6SxiIwGsZ+2UTaD /gg0TrEDcvMs0rgZuDm1jUcCtiQHl1xJneT0o42a/b5sR+ynZLCu825tXXQVZQGHc7t0 ukCTKYo1U/HnJ29ZBe5OFUfPAQrudAlOV8X6NM+Ks19c8r1AdBQGxDRIi9KD51h3Qxi1 GRRU2HrpPxtuBz+172QkLoVrLCpcamknRtgAhA0F7I1uIyb5yh7Z4R75dz2+HYMjpi9a sU8g== X-Gm-Message-State: AOAM532pFufDjAmC5yOvVgIQGnvrrX/uoNJjymvnkJPTUjANNs09EzCs upxkDcrd+H5H0LqO6MPOnk5NOsbwu6dGGuC9OlFrBZvATPvJKx/ZyLEL2YB+EButTD00Nrc7+rE d9Wcojzq0XCENnTVuOxc= X-Received: by 2002:a05:6512:a8e:: with SMTP id m14mr739155lfu.575.1633027780833; Thu, 30 Sep 2021 11:49:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJylKZPrg+EADx0bpkF6s+nUEQRoUtc24razAOy3jT0PBX+t9Qb9QDsK5E5z6KLXXGebvLzNPtSzhP9E+9nQHp8= X-Received: by 2002:a05:6512:a8e:: with SMTP id m14mr739135lfu.575.1633027780623; Thu, 30 Sep 2021 11:49:40 -0700 (PDT) MIME-Version: 1.0 References: <20210924100310.4278-1-zhihongx.peng@intel.com> <20210930125938.266731-1-zhihongx.peng@intel.com> In-Reply-To: <20210930125938.266731-1-zhihongx.peng@intel.com> From: David Marchand Date: Thu, 30 Sep 2021 20:49:29 +0200 Message-ID: To: Zhihong Peng Cc: "Burakov, Anatoly" , "Ananyev, Konstantin" , Stephen Hemminger , dev , Xueqin Lin Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dmarchan@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Subject: Re: [dpdk-dev] [PATCH v6 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 Thu, Sep 30, 2021 at 3:09 PM 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. > > `AddressSanitizer > ` (ASan) > is a widely-used debugging tool to detect memory access errors. > It helps detect issues like use-after-free, various kinds of buffer > overruns in C/C++ programs, and other similar errors, as well as > printing out detailed debug information whenever an error is detected. > > DPDK ASan functionality is currently only supported 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. > > Signed-off-by: Xueqin Lin > Signed-off-by: Zhihong Peng > --- > devtools/words-case.txt | 1 + > doc/guides/prog_guide/ASan.rst | 112 ++++++++++++++++++ > doc/guides/prog_guide/index.rst | 1 + > lib/eal/common/malloc_elem.c | 26 +++- > lib/eal/common/malloc_elem.h | 204 +++++++++++++++++++++++++++++++- > lib/eal/common/malloc_heap.c | 12 ++ > lib/eal/common/rte_malloc.c | 9 +- > 7 files changed, 360 insertions(+), 5 deletions(-) > create mode 100644 doc/guides/prog_guide/ASan.rst > I suppose this makes it a v7 since I can see differences when comparing with "previous" v6 series. Please pay attention to versioning and add a changelog when submitting a new revision. Plus, I had comments on v6: https://inbox.dpdk.org/dev/CAJFAV8yzYJtwpnx+jsaB+X7q7POT86uKC3RS-FB9t7p=kTyGDw@mail.gmail.com/ https://inbox.dpdk.org/dev/CAJFAV8w8Zj5xP+giZtYCUz=4ekuFRDW5Niys9uM6xvAW0kteQg@mail.gmail.com/ Thanks. -- David Marchand