Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/63043/?format=api
http://patches.dpdk.org/api/patches/63043/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/1573829661-16290-1-git-send-email-hkalra@marvell.com/", "project": { "id": 1, "url": "http://patches.dpdk.org/api/projects/1/?format=api", "name": "DPDK", "link_name": "dpdk", "list_id": "dev.dpdk.org", "list_email": "dev@dpdk.org", "web_url": "http://core.dpdk.org", "scm_url": "git://dpdk.org/dpdk", "webscm_url": "http://git.dpdk.org/dpdk", "list_archive_url": "https://inbox.dpdk.org/dev", "list_archive_url_format": "https://inbox.dpdk.org/dev/{}", "commit_url_format": "" }, "msgid": "<1573829661-16290-1-git-send-email-hkalra@marvell.com>", "list_archive_url": "https://inbox.dpdk.org/dev/1573829661-16290-1-git-send-email-hkalra@marvell.com", "date": "2019-11-15T14:54:44", "name": "[v2] mk: add support for UBSAN", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "fd1cf35938525c77094068355a841ce8b357712a", "submitter": { "id": 1182, "url": "http://patches.dpdk.org/api/people/1182/?format=api", "name": "Harman Kalra", "email": "hkalra@marvell.com" }, "delegate": null, "mbox": "http://patches.dpdk.org/project/dpdk/patch/1573829661-16290-1-git-send-email-hkalra@marvell.com/mbox/", "series": [ { "id": 7477, "url": "http://patches.dpdk.org/api/series/7477/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=7477", "date": "2019-11-15T14:54:44", "name": "[v2] mk: add support for UBSAN", "version": 2, "mbox": "http://patches.dpdk.org/series/7477/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/63043/comments/", "check": "success", "checks": "http://patches.dpdk.org/api/patches/63043/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@inbox.dpdk.org", "Delivered-To": "patchwork@inbox.dpdk.org", "Received": [ "from dpdk.org (dpdk.org [92.243.14.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 8D03FA04C5;\n\tFri, 15 Nov 2019 15:54:51 +0100 (CET)", "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 932CF2C12;\n\tFri, 15 Nov 2019 15:54:50 +0100 (CET)", "from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com\n [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id 4674F2C08\n for <dev@dpdk.org>; Fri, 15 Nov 2019 15:54:49 +0100 (CET)", "from pps.filterd (m0045851.ppops.net [127.0.0.1])\n by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id\n xAFEjEV5028640; Fri, 15 Nov 2019 06:54:48 -0800", "from sc-exch01.marvell.com ([199.233.58.181])\n by mx0b-0016f401.pphosted.com with ESMTP id 2w8whr09r5-1\n (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT);\n Fri, 15 Nov 2019 06:54:48 -0800", "from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH01.marvell.com\n (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Fri, 15 Nov\n 2019 06:54:46 -0800", "from NAM01-BN3-obe.outbound.protection.outlook.com (104.47.33.52) by\n SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server\n (TLS) id\n 15.0.1367.3 via Frontend Transport; Fri, 15 Nov 2019 06:54:46 -0800", "from MN2PR18MB2848.namprd18.prod.outlook.com (20.179.21.149) by\n MN2PR18MB2509.namprd18.prod.outlook.com (20.179.80.213) with Microsoft SMTP\n Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id\n 15.20.2451.23; Fri, 15 Nov 2019 14:54:44 +0000", "from MN2PR18MB2848.namprd18.prod.outlook.com\n ([fe80::a8a7:cb5b:a6a6:9693]) by MN2PR18MB2848.namprd18.prod.outlook.com\n ([fe80::a8a7:cb5b:a6a6:9693%7]) with mapi id 15.20.2451.029; Fri, 15 Nov 2019\n 14:54:44 +0000" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com;\n h=from : to : cc :\n subject : date : message-id : references : in-reply-to : content-type :\n content-transfer-encoding : mime-version; s=pfpt0818;\n bh=SiXOhs0crILZaD+uf1OS/BBCXxU8S+uFIrKssWkVxg0=;\n b=Bm6yfUWzK1ryAdpdvLMsKaCzdj2YFGMV65PF4JIqS4dC2BOOg2n4ozviUVtExVySYAPo\n kqreSOwsi/x7ixUAVRWyIrEe0t95/CVzDPDEbcdCYcEWUn+KHzG3Jve2hLesQ7aTkk2A\n xgoj49XUjnU5Rt7PmB5YhKzKFG1pkNzu2NftUzIXzQU2a+r96/2m1HRUGNco4NIaK+ko\n T+NHQCYXpZ2PWZB5RZut24U9BD/ueCpk4iPjXluwyPlz4JAL8eLL/06ipdHKTTBxSWuF\n BCGtG82EFMdhw3a/yMRMWZT0EnVfQ8clcE4Fa5TPr7rAMBc7l27BzgyVKdrxLyzU1UMM 2w==", "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=marvell.onmicrosoft.com; s=selector1-marvell-onmicrosoft-com;\n h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;\n bh=SiXOhs0crILZaD+uf1OS/BBCXxU8S+uFIrKssWkVxg0=;\n b=Q2ayMJYNsHZO/7Pmumjos3gympkQxiwKjGdXYi3127PRfmNoi0FnqyjwCDtNtcqgCOlh2715j2yaXcOC4VnARY54pIY+M6MFyOulILdzKtYk3qrT4QjmOU5p2OtLVhOt1lIdilLBbFk2I9uQBj9ce6UhGtJhYm+pCruS6gVIMB0=" ], "ARC-Seal": "i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;\n b=Wh2pbfIjhW+CFTTAGksj1PqsOQ2gyAhWh8XMYggGXrvmPkBF6wWxJo4QDiyeeLkzjKQ0SWrd2mtRqes4xbRYnEUmNlOMF2VgqmHCHPgVdywSmE+iOVK9MvsByhaPvvvevRtUGJSzUj07F5Jq1pRbLyWrFvMgqxTUjz5PiTa5gs4NEAvVs513Zi11EOkbMX6XOpPQtpnRJSqudEg2CEPfVFPDNxoxPp8rGPEEoCxBJDW3/uTMiSRbr4wy5OZmhY/t/vCHI3cKSla+MBzAxHvrdv97FPGlc9xCYjvZK8QCXoudTZPFgmtVGcpyVVs4FcjlmYRTRh4rHRkClCudSUhV1w==", "ARC-Message-Signature": "i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;\n s=arcselector9901;\n h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;\n bh=SiXOhs0crILZaD+uf1OS/BBCXxU8S+uFIrKssWkVxg0=;\n b=Kq2T3qZXx6/DfmI8Yd/Ndv59H8gIJNLZO5vcQBy4domqBcVytQJItkHMH69qlXduVNl6E7a6ikZ8CAA8LTToTwb2VzGHdJbYYqkhJY0uu/Cy7MMjTWs4LlwTNaCbGZabWlUDk7BdA6Gv5w+OrPIVLMhFp6lylPo7NcjAvjSJmQew5Dvj7MvYQrldLIVRhjU1OZinL3oenIRTGhJhZgkbvLsYvG8jReDtFAbflPfEH+g+fO9y+h+eSMlHfZdO6Eegp73DOyvwHZzn3S5OuK7pI8GHRbee4HKJA5ebcexojDyBa3BxHHRbq2DqhzNECLrajnGfq65lnhGw1gEP2Vtzbg==", "ARC-Authentication-Results": "i=1; mx.microsoft.com 1; spf=pass\n smtp.mailfrom=marvell.com; dmarc=pass action=none header.from=marvell.com;\n dkim=pass header.d=marvell.com; arc=none", "From": "Harman Kalra <hkalra@marvell.com>", "To": "Thomas Monjalon <thomas@monjalon.net>, John McNamara\n <john.mcnamara@intel.com>, Marko Kovacevic <marko.kovacevic@intel.com>,\n \"Bruce Richardson\" <bruce.richardson@intel.com>", "CC": "\"dev@dpdk.org\" <dev@dpdk.org>, Harman Kalra <hkalra@marvell.com>", "Thread-Topic": "[PATCH v2] mk: add support for UBSAN", "Thread-Index": "AQHVm8Se1yPR3c2hMUyWLToFkCw5nQ==", "Date": "Fri, 15 Nov 2019 14:54:44 +0000", "Message-ID": "<1573829661-16290-1-git-send-email-hkalra@marvell.com>", "References": "<20191115144549.GA158812@outlook.office365.com>", "In-Reply-To": "<20191115144549.GA158812@outlook.office365.com>", "Accept-Language": "en-GB, en-US", "Content-Language": "en-US", "X-MS-Has-Attach": "", "X-MS-TNEF-Correlator": "", "x-clientproxiedby": "PN1PR01CA0114.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c00::30)\n To MN2PR18MB2848.namprd18.prod.outlook.com\n (2603:10b6:208:3e::21)", "x-ms-exchange-messagesentrepresentingtype": "1", "x-mailer": "git-send-email 2.7.4", "x-originating-ip": "[115.113.156.2]", "x-ms-publictraffictype": "Email", "x-ms-office365-filtering-correlation-id": "90b435fa-80df-4f07-ca80-08d769dbc061", "x-ms-traffictypediagnostic": "MN2PR18MB2509:", "x-ms-exchange-transport-forked": "True", "x-microsoft-antispam-prvs": "\n <MN2PR18MB2509024D59BD99A1F25F1162C5700@MN2PR18MB2509.namprd18.prod.outlook.com>", "x-ms-oob-tlc-oobclassifiers": "OLM:9508;", "x-forefront-prvs": "02229A4115", "x-forefront-antispam-report": "SFV:NSPM;\n SFS:(10009020)(4636009)(366004)(376002)(346002)(136003)(396003)(39860400002)(189003)(199004)(6486002)(102836004)(6512007)(316002)(478600001)(66946007)(486006)(66556008)(64756008)(66446008)(14454004)(386003)(71190400001)(71200400001)(6506007)(81156014)(6436002)(66476007)(8936002)(305945005)(2906002)(107886003)(4326008)(7736002)(50226002)(36756003)(76176011)(81166006)(8676002)(14444005)(99286004)(52116002)(256004)(26005)(6116002)(55236004)(446003)(66066001)(2616005)(25786009)(476003)(11346002)(86362001)(3846002)(186003)(54906003)(110136005)(5660300002);\n DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR18MB2509;\n H:MN2PR18MB2848.namprd18.prod.outlook.com; FPR:; SPF:None; LANG:en;\n PTR:InfoNoRecords; MX:1; A:1;", "received-spf": "None (protection.outlook.com: marvell.com does not designate\n permitted sender hosts)", "x-ms-exchange-senderadcheck": "1", "x-microsoft-antispam": "BCL:0;", "x-microsoft-antispam-message-info": "\n JBhJuRNHfX1eN+9CZ9gwGYgxDU9KUS674K6Wvv/lCUsLI7H0WcGbkfhnYXO3wWpeK1Z+3QgYwZVlT3mMd0aaQ/Z3EF8JAUs5ZnSW2T8UgMCGRj539A24BvWua55fphQjgAylSCX/asjvVfUBuTPReTtLHeK3xDE9tt2hQLe++RCPWxWXWLFln8C/IwjLhsUhrKxyNm24+jtugoPbvOL5hbugEuVtSwfCT3IuzyG9Xv4/7JJVnSzPAAeMoAQOYshMHhFzPqa83XoMzcG7soM0gMfzd0ePqbGoo5gnE74QzZmxu8/CcI2DWtcblUnuiB1+IJZXx+T8sXkVNU7z3YZW9024j1UScUvSiHl0YICNxB2DzsL4Q9Xt/bD9l9/11IP50NEcWMfBY9ixSAbN237fnZmWNQCp3gkU4UxiX6V04ZopMnWYs0zQn/OYrnDiB+rE", "Content-Type": "text/plain; charset=\"iso-8859-1\"", "Content-Transfer-Encoding": "quoted-printable", "MIME-Version": "1.0", "X-MS-Exchange-CrossTenant-Network-Message-Id": "\n 90b435fa-80df-4f07-ca80-08d769dbc061", "X-MS-Exchange-CrossTenant-originalarrivaltime": "15 Nov 2019 14:54:44.4891 (UTC)", "X-MS-Exchange-CrossTenant-fromentityheader": "Hosted", "X-MS-Exchange-CrossTenant-id": "70e1fb47-1155-421d-87fc-2e58f638b6e0", "X-MS-Exchange-CrossTenant-mailboxtype": "HOSTED", "X-MS-Exchange-CrossTenant-userprincipalname": "\n cRRLM/ggdWOz5e+8QOAZBFYedwEQa164Vv8/v+uOqOG3AOH9Fk8PFSA7LCd99sBDTDrKIigvs/QjNA5yDxUW1A==", "X-MS-Exchange-Transport-CrossTenantHeadersStamped": "MN2PR18MB2509", "X-OriginatorOrg": "marvell.com", "X-Proofpoint-Virus-Version": "vendor=fsecure engine=2.50.10434:6.0.95,18.0.572\n definitions=2019-11-15_04:2019-11-15,2019-11-15 signatures=0", "Subject": "[dpdk-dev] [PATCH v2] mk: add support for UBSAN", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.15", "Precedence": "list", "List-Id": "DPDK patches and discussions <dev.dpdk.org>", "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://mails.dpdk.org/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "UndefinedBehaviorSanitizer (UBSan) is a fast undefined behavior\ndetector. UBSan modifies the program at compile-time to catch\nvarious kinds of undefined behavior during program execution.\n\nThis patch introduces support for UBSan to the DPDK.\n\nSee: doc/guides/prog_guide/ubsan.rst for more information.\n\nSigned-off-by: Harman Kalra <hkalra@marvell.com>\n---\n config/common_base | 6 ++\n config/meson.build | 15 ++++\n doc/guides/prog_guide/index.rst | 1 +\n doc/guides/prog_guide/ubsan.rst | 112 +++++++++++++++++++++++++\n doc/guides/rel_notes/release_19_11.rst | 7 ++\n meson_options.txt | 2 +\n mk/rte.app.mk | 8 ++\n mk/rte.lib.mk | 12 +++\n mk/toolchain/clang/rte.vars.mk | 4 +\n mk/toolchain/gcc/rte.vars.mk | 8 ++\n 10 files changed, 175 insertions(+)\n create mode 100644 doc/guides/prog_guide/ubsan.rst", "diff": "diff --git a/config/common_base b/config/common_base\nindex 914277856..f1bb3e0b2 100644\n--- a/config/common_base\n+++ b/config/common_base\n@@ -1098,3 +1098,9 @@ CONFIG_RTE_APP_CRYPTO_PERF=y\n # Compile the eventdev application\n #\n CONFIG_RTE_APP_EVENTDEV=y\n+\n+#\n+# Enable undefined behavior sanitizer\n+#\n+CONFIG_RTE_UBSAN=n\n+CONFIG_RTE_UBSAN_SANITIZE_ALL=n\ndiff --git a/config/meson.build b/config/meson.build\nindex 2b1cb92e7..a43c23f50 100644\n--- a/config/meson.build\n+++ b/config/meson.build\n@@ -238,3 +238,18 @@ if get_option('b_lto')\n \t\tadd_project_link_arguments('-Wno-lto-type-mismatch', language: 'c')\n \tendif\n endif\n+\n+# enable ubsan\n+if get_option('enable_ubsan')\n+\tif cc.has_argument('-fsanitize=undefined')\n+\t\tubsan_dep = cc.find_library('libubsan', required: false)\n+\t\tif ubsan_dep.found()\n+\t\t\tadd_project_arguments('-fsanitize=undefined', language: 'c')\n+\t\t\tadd_project_link_arguments('-fsanitize=undefined', language: 'c')\n+\t\telse\n+\t\t\tmessage('libubsan not found, UBSAN cannot be enabled')\n+\t\tendif\n+\telse\n+\t\tmessage('gcc version does not support UBSAN')\n+\tendif\n+endif\ndiff --git a/doc/guides/prog_guide/index.rst b/doc/guides/prog_guide/index.rst\nindex dc4851c57..911b82a41 100644\n--- a/doc/guides/prog_guide/index.rst\n+++ b/doc/guides/prog_guide/index.rst\n@@ -67,4 +67,5 @@ Programmer's Guide\n writing_efficient_code\n lto\n profile_app\n+ ubsan\n glossary\ndiff --git a/doc/guides/prog_guide/ubsan.rst b/doc/guides/prog_guide/ubsan.rst\nnew file mode 100644\nindex 000000000..cb19f3bd9\n--- /dev/null\n+++ b/doc/guides/prog_guide/ubsan.rst\n@@ -0,0 +1,112 @@\n+.. SPDX-License-Identifier: BSD-3-Clause\n+ Copyright(c) 2019 Marvell International Ltd.\n+\n+The Undefined Behavior Sanitizer - UBSan\n+========================================\n+\n+UndefinedBehaviorSanitizer (UBSan) is a runtime undefined behavior detector.\n+UBSan uses compile-time instrumentation and modifies the program by adding\n+some stubs which perform certain checks before operations that might cause\n+undefined behaviour. If some UB detected, respective _UBSan_handle_* handlers\n+(which are defined in libUBSan library) are called to prints the error message.\n+\n+Some examples of undefined behaviour checks:\n+\n+* Misaligned memory access\n+* Signed integer overflow\n+* Load from/store to an object with insufficient space.\n+* Integer divide by zero as well as INT_MIN / -1 division\n+* Out-of-bounds memory accesses.\n+* Null argument declared with nonnull attribute, returned null from function\n+ which never returns null, null ptr dereference\n+* Variable size array with non-positive length\n+\n+GCC supports this feature since 4.9, however GCC 5.0 onwards has many more\n+checkers implemented.\n+\n+Example UBSan error\n+--------------------\n+\n+Following error was reported when UBSan was enabled:\n+\n+.. code-block:: console\n+\n+ drivers/net/octeontx2/otx2_stats.c:82:26: runtime error: left shift of\n+ 1 by 31 places cannot be represented in type 'int'\n+\n+Code responsible for this error:\n+\n+.. code-block:: c\n+\n+ if (dev->txmap[i] & (1 << 31)) {\n+\n+To fix this error:\n+\n+.. code-block:: c\n+\n+ if (dev->txmap[i] & (1U << 31)) {\n+\n+Usage\n+-----\n+\n+make build\n+^^^^^^^^^^\n+\n+To enable UBSan, enable following configuration:\n+\n+.. code-block:: console\n+\n+ CONFIG_RTE_UBSAN=y\n+\n+UBSan framework supports three modes:\n+\n+1. Enable UBSan on the entire DPDK source code - set following configuration:\n+\n+.. code-block:: console\n+\n+ CONFIG_RTE_UBSAN_SANITIZE_ALL=y\n+\n+2. Enable UBSan on a particular library or PMD - add the following line to the\n+ respective Makefile of the library or PMD\n+ (make sure ``CONFIG_RTE_UBSAN_SANITIZE_ALL=n``). This will instrument only\n+ the library or PMD and not the entire repository.\n+\n+.. code-block:: console\n+\n+ UBSAN_SANITIZE := y\n+\n+3. Disable UBSan for a particular library or PMD - add the following line to\n+ the respective Makefile of the library or PMD. Make sure\n+ ``CONFIG_RTE_UBSAN_SANITIZE_ALL=y`` config is set. This will instrument\n+ entire DPDK repository but not this specific library or PMD.\n+\n+.. code-block:: console\n+\n+ UBSAN_SANITIZE := n\n+\n+.. Note::\n+\n+ Standard DPDK applications like test, testpmd, etc. cannot be\n+ chosen explicitly for UBSan check, like libraries or PMD. The reason is,\n+ say UBSan is enabled for library X, and ``UBSAN_SANITIZE=y`` is not added\n+ in Makefile of app Y which uses X APIs. This will lead to undefined\n+ reference to _UBSan_handle_* handlers as Y is not compiled with UBSan flags.\n+ Hence UBSan check is enabled for all standard DPDK applications as soon as\n+ ``CONFIG_RTE_UBSAN=y`` is set.\n+\n+meson build\n+^^^^^^^^^^^\n+\n+To enable UBSan in meson build system, use following meson build command:\n+\n+**Example usage:**\n+\n+.. code-block:: console\n+\n+ meson build -Denable_ubsan=true\n+ ninja -C build\n+\n+.. Note::\n+\n+ Meson build works only in one mode i.e. UBSan can be enabled for\n+ the entire DPDK sources and not individual libraries or PMD, like make build.\ndiff --git a/doc/guides/rel_notes/release_19_11.rst b/doc/guides/rel_notes/release_19_11.rst\nindex c0045a91f..61fd1bcc2 100644\n--- a/doc/guides/rel_notes/release_19_11.rst\n+++ b/doc/guides/rel_notes/release_19_11.rst\n@@ -294,6 +294,13 @@ New Features\n \n See :doc:`../prog_guide/lto` for more information:\n \n+* **Added Undefined Behavior Sanitizer framework.**\n+\n+ UBSan is a fast runtime undefined behavior detector which uses compile-time\n+ instrumentation and modifies the program by adding some stubs that perform\n+ certain checks before operations that might cause undefined behavior.\n+\n+ See :doc:`../prog_guide/ubsan` for more information:\n \n \n Removed Items\ndiff --git a/meson_options.txt b/meson_options.txt\nindex 89650b0e9..f3b42d2b1 100644\n--- a/meson_options.txt\n+++ b/meson_options.txt\n@@ -10,6 +10,8 @@ option('enable_docs', type: 'boolean', value: false,\n \tdescription: 'build documentation')\n option('enable_kmods', type: 'boolean', value: true,\n \tdescription: 'build kernel modules')\n+option('enable_ubsan', type: 'boolean', value: false,\n+\tdescription: 'Enables undefined behavior sanitizer')\n option('examples', type: 'string', value: '',\n \tdescription: 'Comma-separated list of examples to build by default')\n option('flexran_sdk', type: 'string', value: '',\ndiff --git a/mk/rte.app.mk b/mk/rte.app.mk\nindex 683e3a4e3..1304227cf 100644\n--- a/mk/rte.app.mk\n+++ b/mk/rte.app.mk\n@@ -385,6 +385,14 @@ endif\n \n MAPFLAGS = -Map=$@.map --cref\n \n+#\n+# If UBSAN is enabled, all application will be compiled with\n+# '-fsanitize=undefined' flag\n+#\n+ifeq ($(CONFIG_RTE_UBSAN)$(UBSAN_ENABLE),yy)\n+CFLAGS += -fsanitize=undefined\n+endif\n+\n .PHONY: all\n all: install\n \ndiff --git a/mk/rte.lib.mk b/mk/rte.lib.mk\nindex 4df8849a0..33f5746c8 100644\n--- a/mk/rte.lib.mk\n+++ b/mk/rte.lib.mk\n@@ -29,6 +29,18 @@ CPU_LDFLAGS += --version-script=$(SRCDIR)/$(EXPORT_MAP)\n endif\n endif\n \n+#\n+# If UBSAN is enabled, lib to undergo check can be chosen\n+# by setting UBSAN_SANITIZE=y in respective lib Makefile\n+# else set CONFIG_RTE_UBSAN_SANITIZE_ALL=y to enforce check\n+# on entire repo.\n+#\n+ifeq ($(CONFIG_RTE_UBSAN),y)\n+ifeq ($(UBSAN_ENABLE),y)\n+CFLAGS += $(if $(patsubst %n,,$(CONFIG_RTE_UBSAN_SANITIZE_ALL)$(UBSAN_SANITIZE)) \\\n+\t\t, -fsanitize=undefined)\n+endif\n+endif\n \n _BUILD = $(LIB)\n PREINSTALL = $(SYMLINK-FILES-y)\ndiff --git a/mk/toolchain/clang/rte.vars.mk b/mk/toolchain/clang/rte.vars.mk\nindex 3c49dc568..623780106 100644\n--- a/mk/toolchain/clang/rte.vars.mk\n+++ b/mk/toolchain/clang/rte.vars.mk\n@@ -56,5 +56,9 @@ ifeq ($(shell test $(CLANG_MAJOR_VERSION) -ge 4 && echo 1), 1)\n WERROR_FLAGS += -Wno-address-of-packed-member\n endif\n \n+ifeq ($(CONFIG_RTE_UBSAN),y)\n+UBSAN_ENABLE := y\n+endif\n+\n export CC AS AR LD OBJCOPY OBJDUMP STRIP READELF\n export TOOLCHAIN_CFLAGS TOOLCHAIN_LDFLAGS TOOLCHAIN_ASFLAGS\ndiff --git a/mk/toolchain/gcc/rte.vars.mk b/mk/toolchain/gcc/rte.vars.mk\nindex 9fc704193..43e7d139b 100644\n--- a/mk/toolchain/gcc/rte.vars.mk\n+++ b/mk/toolchain/gcc/rte.vars.mk\n@@ -102,5 +102,13 @@ endif\n # disable packed member unalign warnings\n WERROR_FLAGS += -Wno-address-of-packed-member\n \n+ifeq ($(CONFIG_RTE_UBSAN),y)\n+ifeq ($(shell test $(GCC_VERSION) -lt 49 && echo 1), 1)\n+$(warning UBSAN not supported gcc < 4.9)\n+else\n+UBSAN_ENABLE = y\n+endif\n+endif\n+\n export CC AS AR LD OBJCOPY OBJDUMP STRIP READELF\n export TOOLCHAIN_CFLAGS TOOLCHAIN_LDFLAGS TOOLCHAIN_ASFLAGS\n", "prefixes": [ "v2" ] }{ "id": 63043, "url": "