Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/6151/?format=api
http://patches.dpdk.org/api/patches/6151/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/1436259634-7077-7-git-send-email-david.marchand@6wind.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": "<1436259634-7077-7-git-send-email-david.marchand@6wind.com>", "list_archive_url": "https://inbox.dpdk.org/dev/1436259634-7077-7-git-send-email-david.marchand@6wind.com", "date": "2015-07-07T09:00:34", "name": "[dpdk-dev,6/6] eal/linux: avoid out of bound access", "commit_ref": null, "pull_url": null, "state": "changes-requested", "archived": true, "hash": "98d389345fbb3a2937ae8d103facbec31b8be0c5", "submitter": { "id": 3, "url": "http://patches.dpdk.org/api/people/3/?format=api", "name": "David Marchand", "email": "david.marchand@6wind.com" }, "delegate": null, "mbox": "http://patches.dpdk.org/project/dpdk/patch/1436259634-7077-7-git-send-email-david.marchand@6wind.com/mbox/", "series": [], "comments": "http://patches.dpdk.org/api/patches/6151/comments/", "check": "pending", "checks": "http://patches.dpdk.org/api/patches/6151/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@dpdk.org", "Delivered-To": "patchwork@dpdk.org", "Received": [ "from [92.243.14.124] (localhost [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id 3F2555A87;\n\tTue, 7 Jul 2015 11:00:59 +0200 (CEST)", "from mail-wg0-f53.google.com (mail-wg0-f53.google.com\n\t[74.125.82.53]) by dpdk.org (Postfix) with ESMTP id 8B7FA5A65\n\tfor <dev@dpdk.org>; Tue, 7 Jul 2015 11:00:55 +0200 (CEST)", "by wgbgr6 with SMTP id gr6so7714440wgb.3\n\tfor <dev@dpdk.org>; Tue, 07 Jul 2015 02:00:55 -0700 (PDT)", "from alcyon.dev.6wind.com (6wind.net2.nerim.net. [213.41.151.210])\n\tby mx.google.com with ESMTPSA id\n\ty19sm32737674wia.15.2015.07.07.02.00.54 for <dev@dpdk.org>\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tTue, 07 Jul 2015 02:00:54 -0700 (PDT)" ], "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20130820;\n\th=x-gm-message-state:from:to:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-type:content-transfer-encoding;\n\tbh=+/uM7IXixugr4npyFBbHtEkB6uLg3WW4AQVCJDmlEgY=;\n\tb=IDtBXwdPc0VvQF2MDhwDtpx7COQfO3qBJW6Y+hE9Jg19GIoU6HSxQ114+wS6biHz71\n\tbxiIifQrjDVm3R2dn3n/giAJ5CQboWi40Dpj8k1j8qFHmlzJ2BBJoXRbZBgzmHST3sR9\n\tQjP4lhm31HQJWamsixrX7blIP7OCUP8yJIrY9ZXsWa04+UAIqCzw/gTQZxG1vVT4nAyK\n\tUQiD0Vkn1jY0U/Tl4/5CN68cOzFpgYlSbjj29quSSXECBpMRcqQTaL8RzBnmbRztunG9\n\ty2I+3S+WRmkEP1bWdojUmkDY8TyezEl3jl4JXYcNZonbXkF7vzYQk/cVTocxFC7bL2Cl\n\tIT+w==", "X-Gm-Message-State": "ALoCoQkTQFvIdxx1MYOfbbv9dBqIikg8mPRirghDQQXGMc5LigFGTL7fhy+IQUlSXvcrEZmq9BFl", "X-Received": "by 10.180.75.198 with SMTP id e6mr48684047wiw.37.1436259655446; \n\tTue, 07 Jul 2015 02:00:55 -0700 (PDT)", "From": "David Marchand <david.marchand@6wind.com>", "To": "dev@dpdk.org", "Date": "Tue, 7 Jul 2015 11:00:34 +0200", "Message-Id": "<1436259634-7077-7-git-send-email-david.marchand@6wind.com>", "X-Mailer": "git-send-email 1.7.10.4", "In-Reply-To": "<1436259634-7077-1-git-send-email-david.marchand@6wind.com>", "References": "<1436259634-7077-1-git-send-email-david.marchand@6wind.com>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "Subject": "[dpdk-dev] =?utf-8?q?=5BPATCH_6/6=5D_eal/linux=3A_avoid_out_of_bo?=\n\t=?utf-8?q?und_access?=", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.15", "Precedence": "list", "List-Id": "patches and discussions about DPDK <dev.dpdk.org>", "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://dpdk.org/ml/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "Using IBM advance toolchain on Ubuntu 14.04 (package 8.0-3), gcc is complaining\nabout out of bound accesses.\n\n CC eal_hugepage_info.o\nlib/librte_eal/linuxapp/eal/eal_hugepage_info.c:\nIn function ‘eal_hugepage_info_init’:\nlib/librte_eal/linuxapp/eal/eal_hugepage_info.c:350:35:\nerror: array subscript is above array bounds [-Werror=array-bounds]\n internal_config.hugepage_info[j].hugepage_sz)\n ^\nlib/librte_eal/linuxapp/eal/eal_hugepage_info.c:350:35:\nerror: array subscript is above array bounds [-Werror=array-bounds]\nlib/librte_eal/linuxapp/eal/eal_hugepage_info.c:349:37:\nerror: array subscript is above array bounds [-Werror=array-bounds]\n if (internal_config.hugepage_info[j-1].hugepage_sz <\n ^\nlib/librte_eal/linuxapp/eal/eal_hugepage_info.c:350:35:\nerror: array subscript is above array bounds [-Werror=array-bounds]\n internal_config.hugepage_info[j].hugepage_sz)\n\nLooking at the code, these warnings are invalid from my pov and they disappeared\nwhen upgrading the toolchain to new version (8.0-4).\n\nHowever, the code was buggy (sorting code is wrong), so fix this by using qsort and adding a\ncheck on num_sizes to avoid potential out of bound accesses.\n\nSigned-off-by: David Marchand <david.marchand@6wind.com>\n---\n lib/librte_eal/linuxapp/eal/eal_hugepage_info.c | 31 ++++++++++-------------\n 1 file changed, 14 insertions(+), 17 deletions(-)", "diff": "diff --git a/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c b/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c\nindex df60f6e..2f96164 100644\n--- a/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c\n+++ b/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c\n@@ -184,15 +184,6 @@ get_hugepage_dir(uint64_t hugepage_sz)\n \treturn retval;\n }\n \n-static inline void\n-swap_hpi(struct hugepage_info *a, struct hugepage_info *b)\n-{\n-\tchar buf[sizeof(*a)];\n-\tmemcpy(buf, a, sizeof(buf));\n-\tmemcpy(a, b, sizeof(buf));\n-\tmemcpy(b, buf, sizeof(buf));\n-}\n-\n /*\n * Clear the hugepage directory of whatever hugepage files\n * there are. Checks if the file is locked (i.e.\n@@ -263,6 +254,15 @@ error:\n \treturn -1;\n }\n \n+static int\n+compare_hpi(const void *a, const void *b)\n+{\n+\tconst struct hugepage_info *hpi_a = a;\n+\tconst struct hugepage_info *hpi_b = b;\n+\n+\treturn hpi_b->hugepage_sz - hpi_a->hugepage_sz;\n+}\n+\n /*\n * when we initialize the hugepage info, everything goes\n * to socket 0 by default. it will later get sorted by memory\n@@ -289,6 +289,9 @@ eal_hugepage_info_init(void)\n \t\t\t dirent_start_len) != 0)\n \t\t\tcontinue;\n \n+\t\tif (num_sizes >= MAX_HUGEPAGE_SIZES)\n+\t\t\tbreak;\n+\n \t\thpi = &internal_config.hugepage_info[num_sizes];\n \t\thpi->hugepage_sz =\n \t\t\trte_str_to_size(&dirent->d_name[dirent_start_len]);\n@@ -343,14 +346,8 @@ eal_hugepage_info_init(void)\n \tinternal_config.num_hugepage_sizes = num_sizes;\n \n \t/* sort the page directory entries by size, largest to smallest */\n-\tfor (i = 0; i < num_sizes; i++) {\n-\t\tunsigned j;\n-\t\tfor (j = i+1; j < num_sizes; j++)\n-\t\t\tif (internal_config.hugepage_info[j-1].hugepage_sz <\n-\t\t\t internal_config.hugepage_info[j].hugepage_sz)\n-\t\t\t\tswap_hpi(&internal_config.hugepage_info[j-1],\n-\t\t\t\t\t &internal_config.hugepage_info[j]);\n-\t}\n+\tqsort(&internal_config.hugepage_info[0], num_sizes,\n+\t sizeof(internal_config.hugepage_info[0]), compare_hpi);\n \n \t/* now we have all info, check we have at least one valid size */\n \tfor (i = 0; i < num_sizes; i++)\n", "prefixes": [ "dpdk-dev", "6/6" ] }{ "id": 6151, "url": "