get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 110611,
    "url": "http://patchwork.dpdk.org/api/patches/110611/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/e24732663167d8ddc2b129e2b490166209f09ddb.1651671644.git.anatoly.burakov@intel.com/",
    "project": {
        "id": 1,
        "url": "http://patchwork.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": "<e24732663167d8ddc2b129e2b490166209f09ddb.1651671644.git.anatoly.burakov@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/e24732663167d8ddc2b129e2b490166209f09ddb.1651671644.git.anatoly.burakov@intel.com",
    "date": "2022-05-04T13:40:53",
    "name": "[v1,1/1] malloc: fix ASan handling for unmapped memory",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "5d7e44efb8d393b224d48016781edc33d157e1ff",
    "submitter": {
        "id": 4,
        "url": "http://patchwork.dpdk.org/api/people/4/?format=api",
        "name": "Burakov, Anatoly",
        "email": "anatoly.burakov@intel.com"
    },
    "delegate": {
        "id": 1,
        "url": "http://patchwork.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/e24732663167d8ddc2b129e2b490166209f09ddb.1651671644.git.anatoly.burakov@intel.com/mbox/",
    "series": [
        {
            "id": 22774,
            "url": "http://patchwork.dpdk.org/api/series/22774/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=22774",
            "date": "2022-05-04T13:40:53",
            "name": "[v1,1/1] malloc: fix ASan handling for unmapped memory",
            "version": 1,
            "mbox": "http://patchwork.dpdk.org/series/22774/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/110611/comments/",
    "check": "fail",
    "checks": "http://patchwork.dpdk.org/api/patches/110611/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 62B9BA00C4;\n\tWed,  4 May 2022 15:41:00 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id C06FB427EC;\n\tWed,  4 May 2022 15:40:59 +0200 (CEST)",
            "from mga11.intel.com (mga11.intel.com [192.55.52.93])\n by mails.dpdk.org (Postfix) with ESMTP id 6FEA84069F;\n Wed,  4 May 2022 15:40:57 +0200 (CEST)",
            "from fmsmga002.fm.intel.com ([10.253.24.26])\n by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 04 May 2022 06:40:55 -0700",
            "from silpixa00401191.ir.intel.com ([10.55.128.75])\n by fmsmga002.fm.intel.com with ESMTP; 04 May 2022 06:40:54 -0700"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple;\n d=intel.com; i=@intel.com; q=dns/txt; s=Intel;\n t=1651671657; x=1683207657;\n h=from:to:cc:subject:date:message-id:mime-version:\n content-transfer-encoding;\n bh=farH/r1B79ULPbhgHAPsXBQf+pSGjtAWQzdJVuYaQEI=;\n b=NJN9PE2SDNeOL6f9AAJHqyytVI6RE5qeVdFWEfSCD908dJykraJRw8lz\n 1yasVC0yxA31ad9OtFpdEE+oGg0vrovMDCK4gpsYJqWyL/3+xrTY2D2zu\n qOaaXVlkvoTUAXwEViOWsNSzziKz7ZDigsSvP8wxEy3/TOdkRNajKM9Ge\n T15atMez/Yhv6PPbQMSktpykUIpoc92UL+8vKjwbHwYYgQycY16Z220Yp\n jLuNDUpY2n0VlmIF3DeJV2DvWcHoLVi6Nmaw3e6iSKVu5i38JrUwQzLla\n DFUa/5XfFq61SLFcCnc3mu2A0melIJ1ToFJoC54hWDhHDILle10NygX9Z g==;",
        "X-IronPort-AV": [
            "E=McAfee;i=\"6400,9594,10337\"; a=\"265356457\"",
            "E=Sophos;i=\"5.91,198,1647327600\"; d=\"scan'208\";a=\"265356457\"",
            "E=Sophos;i=\"5.91,198,1647327600\"; d=\"scan'208\";a=\"664474840\""
        ],
        "X-ExtLoop1": "1",
        "From": "Anatoly Burakov <anatoly.burakov@intel.com>",
        "To": "dev@dpdk.org, Xueqin Lin <xueqin.lin@intel.com>,\n Zhihong Peng <zhihongx.peng@intel.com>",
        "Cc": "david.marchand@redhat.com, vladimir.medvedkin@intel.com, stable@dpdk.org",
        "Subject": "[PATCH v1 1/1] malloc: fix ASan handling for unmapped memory",
        "Date": "Wed,  4 May 2022 13:40:53 +0000",
        "Message-Id": "\n <e24732663167d8ddc2b129e2b490166209f09ddb.1651671644.git.anatoly.burakov@intel.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "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"
    },
    "content": "Currently, when we free previously allocated memory, we mark the area as\n\"freed\" for ASan purposes (flag 0xfd). However, sometimes, freeing a\nmalloc element will cause pages to be unmapped from memory and re-backed\nwith anonymous memory again. This may cause ASan's \"use-after-free\"\nerror down the line, because the allocator will try to write into\nmemory areas recently marked as \"freed\".\n\nTo fix this, we need to mark the unmapped memory area as \"available\",\nand fixup surrounding malloc element header/trailers to enable later\nmalloc routines to safely write into new malloc elements' headers or\ntrailers.\n\nFixes: 6cc51b1293ce (\"mem: instrument allocator for ASan\")\nCc: zhihongx.peng@intel.com\nCc: stable@dpdk.org\n\nSigned-off-by: Anatoly Burakov <anatoly.burakov@intel.com>\n---\n lib/eal/common/malloc_heap.c | 35 +++++++++++++++++++++++++++++++++++\n 1 file changed, 35 insertions(+)",
    "diff": "diff --git a/lib/eal/common/malloc_heap.c b/lib/eal/common/malloc_heap.c\nindex 6c572b6f2c..a3d26fcbea 100644\n--- a/lib/eal/common/malloc_heap.c\n+++ b/lib/eal/common/malloc_heap.c\n@@ -861,6 +861,7 @@ malloc_heap_free(struct malloc_elem *elem)\n \tstruct rte_memseg_list *msl;\n \tunsigned int i, n_segs, before_space, after_space;\n \tint ret;\n+\tbool unmapped = false;\n \tconst struct internal_config *internal_conf =\n \t\teal_get_internal_configuration();\n \n@@ -1027,6 +1028,9 @@ malloc_heap_free(struct malloc_elem *elem)\n \t\trequest_to_primary(&req);\n \t}\n \n+\t/* we didn't exit early, meaning we have unmapped some pages */\n+\tunmapped = true;\n+\n \tRTE_LOG(DEBUG, EAL, \"Heap on socket %d was shrunk by %zdMB\\n\",\n \t\tmsl->socket_id, aligned_len >> 20ULL);\n \n@@ -1034,6 +1038,37 @@ malloc_heap_free(struct malloc_elem *elem)\n free_unlock:\n \tasan_set_freezone(asan_ptr, asan_data_len);\n \n+\t/* if we unmapped some memory, we need to do additional work for ASan */\n+\tif (unmapped) {\n+\t\tvoid *asan_end = RTE_PTR_ADD(asan_ptr, asan_data_len);\n+\t\tvoid *aligned_end = RTE_PTR_ADD(aligned_start, aligned_len);\n+\t\tvoid *aligned_trailer = RTE_PTR_SUB(aligned_start,\n+\t\t\t\tMALLOC_ELEM_TRAILER_LEN);\n+\n+\t\t/*\n+\t\t * There was a memory area that was unmapped. This memory area\n+\t\t * will have to be marked as available for ASan, because we will\n+\t\t * want to use it next time it gets mapped again. The OS memory\n+\t\t * protection should trigger a fault on access to these areas\n+\t\t * anyway, so we are not giving up any protection.\n+\t\t */\n+\t\tasan_set_zone(aligned_start, aligned_len, 0x00);\n+\n+\t\t/*\n+\t\t * ...however, when we unmap pages, we create new free elements\n+\t\t * which might have been marked as \"freed\" with an earlier\n+\t\t * `asan_set_freezone` call. So, if there is an area past the\n+\t\t * unmapped space that was marked as freezone for ASan, we need\n+\t\t * to mark the malloc header as available.\n+\t\t */\n+\t\tif (asan_end > aligned_end)\n+\t\t\tasan_set_zone(aligned_end, MALLOC_ELEM_HEADER_LEN, 0x00);\n+\n+\t\t/* if there's space before unmapped memory, mark as available */\n+\t\tif (asan_ptr < aligned_start)\n+\t\t\tasan_set_zone(aligned_trailer, MALLOC_ELEM_TRAILER_LEN, 0x00);\n+\t}\n+\n \trte_spinlock_unlock(&(heap->lock));\n \treturn ret;\n }\n",
    "prefixes": [
        "v1",
        "1/1"
    ]
}