[dpdk-dev] [RFC v2] porting AddressSanitizer feature to DPDK

Jerin Jacob jerinjacobk at gmail.com
Wed Jun 16 13:34:52 CEST 2021


On Wed, Jun 16, 2021 at 2:43 PM Lin, Xueqin <xueqin.lin at intel.com> wrote:
>
> > -----Original Message-----
> > From: Jerin Jacob <jerinjacobk at gmail.com>
> > Sent: Tuesday, June 15, 2021 4:40 PM
> > To: Peng, ZhihongX <zhihongx.peng at intel.com>
> > Cc: Burakov, Anatoly <anatoly.burakov at intel.com>; Ananyev, Konstantin
> > <konstantin.ananyev at intel.com>; Stephen Hemminger
> > <stephen at networkplumber.org>; dpdk-dev <dev at dpdk.org>; Lin, Xueqin
> > <xueqin.lin at intel.com>
> > Subject: Re: [dpdk-dev] [RFC v2] porting AddressSanitizer feature to DPDK
> >
> > On Tue, Jun 15, 2021 at 1:46 PM <zhihongx.peng at intel.com> wrote:
> > >
> > > From: Zhihong Peng <zhihongx.peng at intel.com>
> > >
> > > 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:
> > > -Db_lundef=false -Db_sanitize=address
> >
> > # Thanks for this patch. It is a useful item.
> >
> > # Subject could be changed
> > from:
> > porting AddressSanitizer feature to DPDK to
> > eal: support for  AddressSanitizer
> > or so
>
> Thanks for your positive feedback and review.
> Good point, we will update the title in next version.
>
> >
> > # Could you add a section in the documentation for Sanitizers to document the
> > build time option and other points that users need to know.
>
> Make sense to add build option and key points to document, will add this part in doc
folder.
>
> > We can add other sanitizers such as UBSan etc in the future here
> WIP to research other sanitizer tool.

UBsan is a good candate.
Some old DPDK patch for the same:
http://patches.dpdk.org/project/dpdk/patch/1573832013-18946-1-git-send-email-hkalra@marvell.com/

> >
> > # Add a UT test case to make sure it is working in app/test or so.
>
> This tool could help to detect memory issue, need to change bad code to check if working.

It is better to have a  UT to test things are working. You could add it in
app/test/test_address_sanity.c. Tests can be such that
- Skip if not complied with Sanity enabled
- Pass if the code detects the known bad code. You can have test cases
with pubic rte_ API
that internally exercise the verify your implementation related to
new asan_* APIs.


> Suggest listing demo code and tool capture information for user to try if tool works, also add this part into doc.
>
> >
> > # Also, Please update the release note for this feature.
> Sure, we can update the release note if code merge.

Probably you can send v1 version next i.e change the RFC status to get merged.


>


More information about the dev mailing list