get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/101186/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 101186,
    "url": "http://patches.dpdk.org/api/patches/101186/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20211012094318.1154727-2-zhihongx.peng@intel.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": "<20211012094318.1154727-2-zhihongx.peng@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20211012094318.1154727-2-zhihongx.peng@intel.com",
    "date": "2021-10-12T09:43:17",
    "name": "[v9,2/3] DPDK code adapts to ASan",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": true,
    "hash": "ee235cca4d6f7e08f13e9ec607360e84b1322722",
    "submitter": {
        "id": 1643,
        "url": "http://patches.dpdk.org/api/people/1643/?format=api",
        "name": "Peng, ZhihongX",
        "email": "zhihongx.peng@intel.com"
    },
    "delegate": {
        "id": 24651,
        "url": "http://patches.dpdk.org/api/users/24651/?format=api",
        "username": "dmarchand",
        "first_name": "David",
        "last_name": "Marchand",
        "email": "david.marchand@redhat.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20211012094318.1154727-2-zhihongx.peng@intel.com/mbox/",
    "series": [
        {
            "id": 19549,
            "url": "http://patches.dpdk.org/api/series/19549/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=19549",
            "date": "2021-10-12T09:43:16",
            "name": "[v9,1/3] Enable ASan for memory detector on DPDK",
            "version": 9,
            "mbox": "http://patches.dpdk.org/series/19549/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/101186/comments/",
    "check": "warning",
    "checks": "http://patches.dpdk.org/api/patches/101186/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 mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id CA9BCA0C47;\n\tTue, 12 Oct 2021 11:54:23 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id EEE8D4111E;\n\tTue, 12 Oct 2021 11:54:19 +0200 (CEST)",
            "from mga11.intel.com (mga11.intel.com [192.55.52.93])\n by mails.dpdk.org (Postfix) with ESMTP id C05C04003C\n for <dev@dpdk.org>; Tue, 12 Oct 2021 11:54:17 +0200 (CEST)",
            "from orsmga008.jf.intel.com ([10.7.209.65])\n by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 12 Oct 2021 02:54:17 -0700",
            "from unknown (HELO localhost.localdomain) ([10.240.183.65])\n by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 12 Oct 2021 02:54:14 -0700"
        ],
        "X-IronPort-AV": [
            "E=McAfee;i=\"6200,9189,10134\"; a=\"224519249\"",
            "E=Sophos;i=\"5.85,367,1624345200\"; d=\"scan'208\";a=\"224519249\"",
            "E=Sophos;i=\"5.85,367,1624345200\"; d=\"scan'208\";a=\"490894995\""
        ],
        "From": "zhihongx.peng@intel.com",
        "To": "david.marchand@redhat.com, anatoly.burakov@intel.com,\n konstantin.ananyev@intel.com, stephen@networkplumber.org",
        "Cc": "dev@dpdk.org, xueqin.lin@intel.com, Zhihong Peng <zhihongx.peng@intel.com>",
        "Date": "Tue, 12 Oct 2021 09:43:17 +0000",
        "Message-Id": "<20211012094318.1154727-2-zhihongx.peng@intel.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<20211012094318.1154727-1-zhihongx.peng@intel.com>",
        "References": "<20211011062810.422220-1-zhihongx.peng@intel.com>\n <20211012094318.1154727-1-zhihongx.peng@intel.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[dpdk-dev] [PATCH v9 2/3] DPDK code adapts to ASan",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "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": "From: Zhihong Peng <zhihongx.peng@intel.com>\n\nDPDK ASan functionality is currently only supported Linux x86_64.\nSupport other platforms, need to define ASAN_SHADOW_OFFSET value\naccording to google ASan document, and configure meson\n(config/meson.build).\n\nSigned-off-by: Xueqin Lin <xueqin.lin@intel.com>\nSigned-off-by: Zhihong Peng <zhihongx.peng@intel.com>\n---\nv7: Split doc and code into two.\nv8: No change.\nv9: Modify the definition of RTE_MALLOC_ASAN.\n---\n config/meson.build           |   2 +\n lib/eal/common/malloc_elem.c |  26 ++++-\n lib/eal/common/malloc_elem.h | 194 ++++++++++++++++++++++++++++++++++-\n lib/eal/common/malloc_heap.c |  12 +++\n lib/eal/common/rte_malloc.c  |   9 +-\n 5 files changed, 238 insertions(+), 5 deletions(-)",
    "diff": "diff --git a/config/meson.build b/config/meson.build\nindex 5170b79fed..1ae9390e68 100644\n--- a/config/meson.build\n+++ b/config/meson.build\n@@ -419,6 +419,8 @@ if get_option('b_sanitize') == 'address'\n             error('broken dependency, \"libasan\"')\n         endif\n     endif\n+\n+    dpdk_conf.set10('RTE_MALLOC_ASAN', true)\n endif\n \n if get_option('default_library') == 'both'\ndiff --git a/lib/eal/common/malloc_elem.c b/lib/eal/common/malloc_elem.c\nindex c2c9461f1d..bdd20a162e 100644\n--- a/lib/eal/common/malloc_elem.c\n+++ b/lib/eal/common/malloc_elem.c\n@@ -446,6 +446,8 @@ malloc_elem_alloc(struct malloc_elem *elem, size_t size, unsigned align,\n \t\tstruct malloc_elem *new_free_elem =\n \t\t\t\tRTE_PTR_ADD(new_elem, size + MALLOC_ELEM_OVERHEAD);\n \n+\t\tasan_clear_split_alloczone(new_free_elem);\n+\n \t\tsplit_elem(elem, new_free_elem);\n \t\tmalloc_elem_free_list_insert(new_free_elem);\n \n@@ -458,6 +460,8 @@ malloc_elem_alloc(struct malloc_elem *elem, size_t size, unsigned align,\n \t\telem->state = ELEM_BUSY;\n \t\telem->pad = old_elem_size;\n \n+\t\tasan_clear_alloczone(elem);\n+\n \t\t/* put a dummy header in padding, to point to real element header */\n \t\tif (elem->pad > 0) { /* pad will be at least 64-bytes, as everything\n \t\t                     * is cache-line aligned */\n@@ -470,12 +474,18 @@ malloc_elem_alloc(struct malloc_elem *elem, size_t size, unsigned align,\n \t\treturn new_elem;\n \t}\n \n+\tasan_clear_split_alloczone(new_elem);\n+\n \t/* we are going to split the element in two. The original element\n \t * remains free, and the new element is the one allocated.\n \t * Re-insert original element, in case its new size makes it\n \t * belong on a different list.\n \t */\n+\n \tsplit_elem(elem, new_elem);\n+\n+\tasan_clear_alloczone(new_elem);\n+\n \tnew_elem->state = ELEM_BUSY;\n \tmalloc_elem_free_list_insert(elem);\n \n@@ -601,6 +611,8 @@ malloc_elem_hide_region(struct malloc_elem *elem, void *start, size_t len)\n \tif (next && next_elem_is_adjacent(elem)) {\n \t\tlen_after = RTE_PTR_DIFF(next, hide_end);\n \t\tif (len_after >= MALLOC_ELEM_OVERHEAD + MIN_DATA_SIZE) {\n+\t\t\tasan_clear_split_alloczone(hide_end);\n+\n \t\t\t/* split after */\n \t\t\tsplit_elem(elem, hide_end);\n \n@@ -615,6 +627,8 @@ malloc_elem_hide_region(struct malloc_elem *elem, void *start, size_t len)\n \tif (prev && prev_elem_is_adjacent(elem)) {\n \t\tlen_before = RTE_PTR_DIFF(hide_start, elem);\n \t\tif (len_before >= MALLOC_ELEM_OVERHEAD + MIN_DATA_SIZE) {\n+\t\t\tasan_clear_split_alloczone(hide_start);\n+\n \t\t\t/* split before */\n \t\t\tsplit_elem(elem, hide_start);\n \n@@ -628,6 +642,8 @@ malloc_elem_hide_region(struct malloc_elem *elem, void *start, size_t len)\n \t\t}\n \t}\n \n+\tasan_clear_alloczone(elem);\n+\n \tremove_elem(elem);\n }\n \n@@ -641,8 +657,10 @@ malloc_elem_resize(struct malloc_elem *elem, size_t size)\n \tconst size_t new_size = size + elem->pad + MALLOC_ELEM_OVERHEAD;\n \n \t/* if we request a smaller size, then always return ok */\n-\tif (elem->size >= new_size)\n+\tif (elem->size >= new_size) {\n+\t\tasan_clear_alloczone(elem);\n \t\treturn 0;\n+\t}\n \n \t/* check if there is a next element, it's free and adjacent */\n \tif (!elem->next || elem->next->state != ELEM_FREE ||\n@@ -661,9 +679,15 @@ malloc_elem_resize(struct malloc_elem *elem, size_t size)\n \t\t/* now we have a big block together. Lets cut it down a bit, by splitting */\n \t\tstruct malloc_elem *split_pt = RTE_PTR_ADD(elem, new_size);\n \t\tsplit_pt = RTE_PTR_ALIGN_CEIL(split_pt, RTE_CACHE_LINE_SIZE);\n+\n+\t\tasan_clear_split_alloczone(split_pt);\n+\n \t\tsplit_elem(elem, split_pt);\n \t\tmalloc_elem_free_list_insert(split_pt);\n \t}\n+\n+\tasan_clear_alloczone(elem);\n+\n \treturn 0;\n }\n \ndiff --git a/lib/eal/common/malloc_elem.h b/lib/eal/common/malloc_elem.h\nindex a1e5f7f02c..a06c11ac8b 100644\n--- a/lib/eal/common/malloc_elem.h\n+++ b/lib/eal/common/malloc_elem.h\n@@ -36,10 +36,20 @@ struct malloc_elem {\n \tuint64_t header_cookie;         /* Cookie marking start of data */\n \t                                /* trailer cookie at start + size */\n #endif\n+#ifdef RTE_MALLOC_ASAN\n+\tsize_t user_size;\n+\tuint64_t asan_cookie[2]; /* must be next to header_cookie */\n+#endif\n } __rte_cache_aligned;\n \n+static const unsigned int MALLOC_ELEM_HEADER_LEN = sizeof(struct malloc_elem);\n+\n #ifndef RTE_MALLOC_DEBUG\n-static const unsigned MALLOC_ELEM_TRAILER_LEN = 0;\n+#ifdef RTE_MALLOC_ASAN\n+static const unsigned int MALLOC_ELEM_TRAILER_LEN = RTE_CACHE_LINE_SIZE;\n+#else\n+static const unsigned int MALLOC_ELEM_TRAILER_LEN;\n+#endif\n \n /* dummy function - just check if pointer is non-null */\n static inline int\n@@ -55,7 +65,7 @@ set_trailer(struct malloc_elem *elem __rte_unused){ }\n \n \n #else\n-static const unsigned MALLOC_ELEM_TRAILER_LEN = RTE_CACHE_LINE_SIZE;\n+static const unsigned int MALLOC_ELEM_TRAILER_LEN = RTE_CACHE_LINE_SIZE;\n \n #define MALLOC_HEADER_COOKIE   0xbadbadbadadd2e55ULL /**< Header cookie. */\n #define MALLOC_TRAILER_COOKIE  0xadd2e55badbadbadULL /**< Trailer cookie.*/\n@@ -90,9 +100,187 @@ malloc_elem_cookies_ok(const struct malloc_elem *elem)\n \n #endif\n \n-static const unsigned MALLOC_ELEM_HEADER_LEN = sizeof(struct malloc_elem);\n #define MALLOC_ELEM_OVERHEAD (MALLOC_ELEM_HEADER_LEN + MALLOC_ELEM_TRAILER_LEN)\n \n+#ifdef RTE_MALLOC_ASAN\n+\n+#ifdef RTE_ARCH_X86_64\n+#define ASAN_SHADOW_OFFSET    0x00007fff8000\n+#endif\n+\n+#define ASAN_SHADOW_GRAIN_SIZE\t8\n+#define ASAN_MEM_FREE_FLAG\t0xfd\n+#define ASAN_MEM_REDZONE_FLAG\t0xfa\n+#define ASAN_SHADOW_SCALE    3\n+\n+#define ASAN_MEM_SHIFT(mem) ((void *)((uintptr_t)(mem) >> ASAN_SHADOW_SCALE))\n+#define ASAN_MEM_TO_SHADOW(mem) \\\n+\tRTE_PTR_ADD(ASAN_MEM_SHIFT(mem), ASAN_SHADOW_OFFSET)\n+\n+#if defined(__clang__)\n+__attribute__((no_sanitize(\"address\", \"hwaddress\")))\n+#else\n+__attribute__((no_sanitize_address))\n+#endif\n+static inline void\n+asan_set_shadow(void *addr, char val)\n+{\n+\t*(char *)addr = val;\n+}\n+\n+static inline void\n+asan_set_zone(void *ptr, size_t len, uint32_t val)\n+{\n+\tsize_t offset, i;\n+\tvoid *shadow;\n+\tsize_t zone_len = len / ASAN_SHADOW_GRAIN_SIZE;\n+\tif (len % ASAN_SHADOW_GRAIN_SIZE != 0)\n+\t\tzone_len += 1;\n+\n+\tfor (i = 0; i < zone_len; i++) {\n+\t\toffset = i * ASAN_SHADOW_GRAIN_SIZE;\n+\t\tshadow = ASAN_MEM_TO_SHADOW((uintptr_t)ptr + offset);\n+\t\tasan_set_shadow(shadow, val);\n+\t}\n+}\n+\n+/*\n+ * When the memory is released, the release mark is\n+ * set in the corresponding range of the shadow area.\n+ */\n+static inline void\n+asan_set_freezone(void *ptr, size_t size)\n+{\n+\tasan_set_zone(ptr, size, ASAN_MEM_FREE_FLAG);\n+}\n+\n+/*\n+ * When the memory is allocated, memory state must set as accessible.\n+ */\n+static inline void\n+asan_clear_alloczone(struct malloc_elem *elem)\n+{\n+\tasan_set_zone((void *)elem, elem->size, 0x0);\n+}\n+\n+static inline void\n+asan_clear_split_alloczone(struct malloc_elem *elem)\n+{\n+\tvoid *ptr = RTE_PTR_SUB(elem, MALLOC_ELEM_TRAILER_LEN);\n+\tasan_set_zone(ptr, MALLOC_ELEM_OVERHEAD, 0x0);\n+}\n+\n+/*\n+ * When the memory is allocated, the memory boundary is\n+ * marked in the corresponding range of the shadow area.\n+ * Requirement: redzone >= 16, is a power of two.\n+ */\n+static inline void\n+asan_set_redzone(struct malloc_elem *elem, size_t user_size)\n+{\n+\tuintptr_t head_redzone;\n+\tuintptr_t tail_redzone;\n+\tvoid *front_shadow;\n+\tvoid *tail_shadow;\n+\tuint32_t val;\n+\n+\tif (elem != NULL) {\n+\t\tif (elem->state != ELEM_PAD)\n+\t\t\telem = RTE_PTR_ADD(elem, elem->pad);\n+\n+\t\telem->user_size = user_size;\n+\n+\t\t/* Set mark before the start of the allocated memory */\n+\t\thead_redzone = (uintptr_t)RTE_PTR_ADD(elem,\n+\t\t\tMALLOC_ELEM_HEADER_LEN - ASAN_SHADOW_GRAIN_SIZE);\n+\t\tfront_shadow = ASAN_MEM_TO_SHADOW(head_redzone);\n+\t\tasan_set_shadow(front_shadow, ASAN_MEM_REDZONE_FLAG);\n+\t\tfront_shadow = ASAN_MEM_TO_SHADOW(head_redzone\n+\t\t\t- ASAN_SHADOW_GRAIN_SIZE);\n+\t\tasan_set_shadow(front_shadow, ASAN_MEM_REDZONE_FLAG);\n+\n+\t\t/* Set mark after the end of the allocated memory */\n+\t\ttail_redzone = (uintptr_t)RTE_PTR_ADD(elem,\n+\t\t\tMALLOC_ELEM_HEADER_LEN\n+\t\t\t+ elem->user_size);\n+\t\ttail_shadow = ASAN_MEM_TO_SHADOW(tail_redzone);\n+\t\tval = (tail_redzone % ASAN_SHADOW_GRAIN_SIZE);\n+\t\tval = (val == 0) ? ASAN_MEM_REDZONE_FLAG : val;\n+\t\tasan_set_shadow(tail_shadow, val);\n+\t\ttail_shadow = ASAN_MEM_TO_SHADOW(tail_redzone\n+\t\t\t+ ASAN_SHADOW_GRAIN_SIZE);\n+\t\tasan_set_shadow(tail_shadow, ASAN_MEM_REDZONE_FLAG);\n+\t}\n+}\n+\n+/*\n+ * When the memory is released, the mark of the memory boundary\n+ * in the corresponding range of the shadow area is cleared.\n+ * Requirement: redzone >= 16, is a power of two.\n+ */\n+static inline void\n+asan_clear_redzone(struct malloc_elem *elem)\n+{\n+\tuintptr_t head_redzone;\n+\tuintptr_t tail_redzone;\n+\tvoid *head_shadow;\n+\tvoid *tail_shadow;\n+\n+\tif (elem != NULL) {\n+\t\telem = RTE_PTR_ADD(elem, elem->pad);\n+\n+\t\t/* Clear mark before the start of the allocated memory */\n+\t\thead_redzone = (uintptr_t)RTE_PTR_ADD(elem,\n+\t\t\tMALLOC_ELEM_HEADER_LEN - ASAN_SHADOW_GRAIN_SIZE);\n+\t\thead_shadow = ASAN_MEM_TO_SHADOW(head_redzone);\n+\t\tasan_set_shadow(head_shadow, 0x00);\n+\t\thead_shadow = ASAN_MEM_TO_SHADOW(head_redzone\n+\t\t\t\t- ASAN_SHADOW_GRAIN_SIZE);\n+\t\tasan_set_shadow(head_shadow, 0x00);\n+\n+\t\t/* Clear mark after the end of the allocated memory */\n+\t\ttail_redzone = (uintptr_t)RTE_PTR_ADD(elem,\n+\t\t\tMALLOC_ELEM_HEADER_LEN + elem->user_size);\n+\t\ttail_shadow = ASAN_MEM_TO_SHADOW(tail_redzone);\n+\t\tasan_set_shadow(tail_shadow, 0x00);\n+\t\ttail_shadow = ASAN_MEM_TO_SHADOW(tail_redzone\n+\t\t\t\t+ ASAN_SHADOW_GRAIN_SIZE);\n+\t\tasan_set_shadow(tail_shadow, 0x00);\n+\t}\n+}\n+\n+static inline size_t\n+old_malloc_size(struct malloc_elem *elem)\n+{\n+\tif (elem->state != ELEM_PAD)\n+\t\telem = RTE_PTR_ADD(elem, elem->pad);\n+\n+\treturn elem->user_size;\n+}\n+#else\n+static inline void\n+asan_set_freezone(void *ptr __rte_unused, size_t size __rte_unused) { }\n+\n+static inline void\n+asan_clear_alloczone(struct malloc_elem *elem __rte_unused) { }\n+\n+static inline void\n+asan_clear_split_alloczone(struct malloc_elem *elem __rte_unused) { }\n+\n+static inline void\n+asan_set_redzone(struct malloc_elem *elem __rte_unused,\n+\t\t\t\t\tsize_t user_size __rte_unused) { }\n+\n+static inline void\n+asan_clear_redzone(struct malloc_elem *elem __rte_unused) { }\n+\n+static inline size_t\n+old_malloc_size(struct malloc_elem *elem)\n+{\n+\treturn elem->size - elem->pad - MALLOC_ELEM_OVERHEAD;\n+}\n+#endif\n+\n /*\n  * Given a pointer to the start of a memory block returned by malloc, get\n  * the actual malloc_elem header for that block.\ndiff --git a/lib/eal/common/malloc_heap.c b/lib/eal/common/malloc_heap.c\nindex ee400f38ec..775d6789df 100644\n--- a/lib/eal/common/malloc_heap.c\n+++ b/lib/eal/common/malloc_heap.c\n@@ -237,6 +237,7 @@ heap_alloc(struct malloc_heap *heap, const char *type __rte_unused, size_t size,\n \t\tunsigned int flags, size_t align, size_t bound, bool contig)\n {\n \tstruct malloc_elem *elem;\n+\tsize_t user_size = size;\n \n \tsize = RTE_CACHE_LINE_ROUNDUP(size);\n \talign = RTE_CACHE_LINE_ROUNDUP(align);\n@@ -250,6 +251,8 @@ heap_alloc(struct malloc_heap *heap, const char *type __rte_unused, size_t size,\n \n \t\t/* increase heap's count of allocated elements */\n \t\theap->alloc_count++;\n+\n+\t\tasan_set_redzone(elem, user_size);\n \t}\n \n \treturn elem == NULL ? NULL : (void *)(&elem[1]);\n@@ -270,6 +273,8 @@ heap_alloc_biggest(struct malloc_heap *heap, const char *type __rte_unused,\n \n \t\t/* increase heap's count of allocated elements */\n \t\theap->alloc_count++;\n+\n+\t\tasan_set_redzone(elem, size);\n \t}\n \n \treturn elem == NULL ? NULL : (void *)(&elem[1]);\n@@ -841,6 +846,8 @@ malloc_heap_free(struct malloc_elem *elem)\n \tif (!malloc_elem_cookies_ok(elem) || elem->state != ELEM_BUSY)\n \t\treturn -1;\n \n+\tasan_clear_redzone(elem);\n+\n \t/* elem may be merged with previous element, so keep heap address */\n \theap = elem->heap;\n \tmsl = elem->msl;\n@@ -848,6 +855,9 @@ malloc_heap_free(struct malloc_elem *elem)\n \n \trte_spinlock_lock(&(heap->lock));\n \n+\tvoid *asan_ptr = RTE_PTR_ADD(elem, MALLOC_ELEM_HEADER_LEN + elem->pad);\n+\tsize_t asan_data_len = elem->size - MALLOC_ELEM_OVERHEAD - elem->pad;\n+\n \t/* mark element as free */\n \telem->state = ELEM_FREE;\n \n@@ -1001,6 +1011,8 @@ malloc_heap_free(struct malloc_elem *elem)\n \n \trte_mcfg_mem_write_unlock();\n free_unlock:\n+\tasan_set_freezone(asan_ptr, asan_data_len);\n+\n \trte_spinlock_unlock(&(heap->lock));\n \treturn ret;\n }\ndiff --git a/lib/eal/common/rte_malloc.c b/lib/eal/common/rte_malloc.c\nindex 9d39e58c08..d0bec26920 100644\n--- a/lib/eal/common/rte_malloc.c\n+++ b/lib/eal/common/rte_malloc.c\n@@ -162,6 +162,8 @@ rte_calloc(const char *type, size_t num, size_t size, unsigned align)\n void *\n rte_realloc_socket(void *ptr, size_t size, unsigned int align, int socket)\n {\n+\tsize_t user_size;\n+\n \tif (ptr == NULL)\n \t\treturn rte_malloc_socket(NULL, size, align, socket);\n \n@@ -171,6 +173,8 @@ rte_realloc_socket(void *ptr, size_t size, unsigned int align, int socket)\n \t\treturn NULL;\n \t}\n \n+\tuser_size = size;\n+\n \tsize = RTE_CACHE_LINE_ROUNDUP(size), align = RTE_CACHE_LINE_ROUNDUP(align);\n \n \t/* check requested socket id and alignment matches first, and if ok,\n@@ -181,6 +185,9 @@ rte_realloc_socket(void *ptr, size_t size, unsigned int align, int socket)\n \t\t\tRTE_PTR_ALIGN(ptr, align) == ptr &&\n \t\t\tmalloc_heap_resize(elem, size) == 0) {\n \t\trte_eal_trace_mem_realloc(size, align, socket, ptr);\n+\n+\t\tasan_set_redzone(elem, user_size);\n+\n \t\treturn ptr;\n \t}\n \n@@ -192,7 +199,7 @@ rte_realloc_socket(void *ptr, size_t size, unsigned int align, int socket)\n \tif (new_ptr == NULL)\n \t\treturn NULL;\n \t/* elem: |pad|data_elem|data|trailer| */\n-\tconst size_t old_size = elem->size - elem->pad - MALLOC_ELEM_OVERHEAD;\n+\tconst size_t old_size = old_malloc_size(elem);\n \trte_memcpy(new_ptr, ptr, old_size < size ? old_size : size);\n \trte_free(ptr);\n \n",
    "prefixes": [
        "v9",
        "2/3"
    ]
}