get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 44502,
    "url": "http://patches.dpdk.org/api/patches/44502/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1536572016-18134-33-git-send-email-arybchenko@solarflare.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": "<1536572016-18134-33-git-send-email-arybchenko@solarflare.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1536572016-18134-33-git-send-email-arybchenko@solarflare.com",
    "date": "2018-09-10T09:33:31",
    "name": "[32/37] net/sfc/base: check buffer size for hash flags",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "09bdd854ee2ea847b879415077ca43cf640e2dd3",
    "submitter": {
        "id": 607,
        "url": "http://patches.dpdk.org/api/people/607/?format=api",
        "name": "Andrew Rybchenko",
        "email": "arybchenko@solarflare.com"
    },
    "delegate": {
        "id": 319,
        "url": "http://patches.dpdk.org/api/users/319/?format=api",
        "username": "fyigit",
        "first_name": "Ferruh",
        "last_name": "Yigit",
        "email": "ferruh.yigit@amd.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/1536572016-18134-33-git-send-email-arybchenko@solarflare.com/mbox/",
    "series": [
        {
            "id": 1244,
            "url": "http://patches.dpdk.org/api/series/1244/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=1244",
            "date": "2018-09-10T09:33:01",
            "name": "net/sfc: update base driver",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/1244/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/44502/comments/",
    "check": "warning",
    "checks": "http://patches.dpdk.org/api/patches/44502/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 [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id E3CF41B051;\n\tMon, 10 Sep 2018 11:34:46 +0200 (CEST)",
            "from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com\n\t[67.231.154.164]) by dpdk.org (Postfix) with ESMTP id 223EB4CA2\n\tfor <dev@dpdk.org>; Mon, 10 Sep 2018 11:33:55 +0200 (CEST)",
            "from webmail.solarflare.com (webmail.solarflare.com\n\t[12.187.104.26])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby mx1-us1.ppe-hosted.com (Proofpoint Essentials ESMTP Server) with\n\tESMTPS id 3AC60780055; Mon, 10 Sep 2018 09:33:54 +0000 (UTC)",
            "from ocex03.SolarFlarecom.com (10.20.40.36) by\n\tocex03.SolarFlarecom.com (10.20.40.36) with Microsoft SMTP Server\n\t(TLS) id 15.0.1395.4; Mon, 10 Sep 2018 02:33:49 -0700",
            "from opal.uk.solarflarecom.com (10.17.10.1) by\n\tocex03.SolarFlarecom.com (10.20.40.36) with Microsoft SMTP Server\n\t(TLS) id\n\t15.0.1395.4 via Frontend Transport; Mon, 10 Sep 2018 02:33:48 -0700",
            "from ukv-loginhost.uk.solarflarecom.com\n\t(ukv-loginhost.uk.solarflarecom.com [10.17.10.39])\n\tby opal.uk.solarflarecom.com (8.13.8/8.13.8) with ESMTP id\n\tw8A9XlTm023879; Mon, 10 Sep 2018 10:33:47 +0100",
            "from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1])\n\tby ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id\n\t11D341626D1; Mon, 10 Sep 2018 10:33:47 +0100 (BST)"
        ],
        "X-Virus-Scanned": "Proofpoint Essentials engine",
        "From": "Andrew Rybchenko <arybchenko@solarflare.com>",
        "To": "<dev@dpdk.org>",
        "CC": "Ivan Malov <Ivan.Malov@oktetlabs.ru>",
        "Date": "Mon, 10 Sep 2018 10:33:31 +0100",
        "Message-ID": "<1536572016-18134-33-git-send-email-arybchenko@solarflare.com>",
        "X-Mailer": "git-send-email 1.8.3.1",
        "In-Reply-To": "<1536572016-18134-1-git-send-email-arybchenko@solarflare.com>",
        "References": "<1536572016-18134-1-git-send-email-arybchenko@solarflare.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain",
        "X-TM-AS-Product-Ver": "SMEX-12.5.0.1300-8.5.1010-24084.005",
        "X-TM-AS-Result": "No-0.078400-4.000000-10",
        "X-TMASE-MatchedRID": "bCexVCeAAegcRhEjx02trsy6PPK75b2Bh+w9Wz/xXDp8vx8dQICa63B4\n\t4IkzjfYy5yqn9lwStLQdVH0mm1n6eXVkgEm9JWcdt1AhvyEKdj4z2D5h92okoT9zwv61WVRWG/+\n\tuOKd48QdWRiTC9kBY19lvJAfOnLVeQF24kZp9Ww9xgZi4qPpiYDVPM/rRSR0du6qThyrnanNzk0\n\tIMokNJUFYJIpN1DYJ5gDLqnrRlXrZLA5JD98yI6t0H8LFZNFG7CKFCmhdu5cVsmdlru1Te+d4O1\n\tlY1um9IMy6jLOoUPfRKT+XtJWcTTqZM+7qcL7KLZqM6OE0nzDxaHAJn4lNzgo67Dhyk3FBbGi8w\n\tTA3XNvcPXLxHfxLeXVRHOSKs7RDUXmH0pBaurgG+4xOvsJAknvqy+VVvqH2X",
        "X-TM-AS-User-Approved-Sender": "No",
        "X-TM-AS-User-Blocked-Sender": "No",
        "X-TMASE-Result": "10-0.078400-4.000000",
        "X-TMASE-Version": "SMEX-12.5.0.1300-8.5.1010-24084.005",
        "X-MDID": "1536572034-jqKyVT37mzu8",
        "Subject": "[dpdk-dev] [PATCH 32/37] net/sfc/base: check buffer size for hash\n\tflags",
        "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\t<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\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "From: Ivan Malov <Ivan.Malov@oktetlabs.ru>\n\nThe efx_rx_scale_hash_flags_get interface is unsafe, as it does not\nhave an argument for the size of the output buffer used to return\nthe flags. While the only caller currently supplies a sufficiently\nlarge buffer, this should be checked at runtime to avoid writing\npast the end of the buffer.\n\nSigned-off-by: Ivan Malov <Ivan.Malov@oktetlabs.ru>\nSigned-off-by: Andrew Rybchenko <arybchenko@solarflare.com>\n---\n drivers/net/sfc/base/efx.h        |   3 +-\n drivers/net/sfc/base/efx_annote.h |   1 +\n drivers/net/sfc/base/efx_rx.c     | 120 +++++++++++++++++++-----------\n drivers/net/sfc/sfc_rx.c          |   2 +-\n 4 files changed, 81 insertions(+), 45 deletions(-)",
    "diff": "diff --git a/drivers/net/sfc/base/efx.h b/drivers/net/sfc/base/efx.h\nindex cc68f744e..de62b7d50 100644\n--- a/drivers/net/sfc/base/efx.h\n+++ b/drivers/net/sfc/base/efx.h\n@@ -2368,7 +2368,8 @@ extern\t__checkReturn\t\t\t\tefx_rc_t\n efx_rx_scale_hash_flags_get(\n \t__in\t\t\t\t\tefx_nic_t *enp,\n \t__in\t\t\t\t\tefx_rx_hash_alg_t hash_alg,\n-\t__inout_ecount(EFX_RX_HASH_NFLAGS)\tunsigned int *flagsp,\n+\t__out_ecount_part(max_nflags, *nflagsp)\tunsigned int *flagsp,\n+\t__in\t\t\t\t\tunsigned int max_nflags,\n \t__out\t\t\t\t\tunsigned int *nflagsp);\n \n extern\t__checkReturn\tefx_rc_t\ndiff --git a/drivers/net/sfc/base/efx_annote.h b/drivers/net/sfc/base/efx_annote.h\nindex 671aaed3b..607b43c77 100644\n--- a/drivers/net/sfc/base/efx_annote.h\n+++ b/drivers/net/sfc/base/efx_annote.h\n@@ -33,6 +33,7 @@\n #define\t__out_opt\n #define\t__out_ecount(_n)\n #define\t__out_ecount_opt(_n)\n+#define\t__out_ecount_part(_n, _l)\n #define\t__out_bcount(_n)\n #define\t__out_bcount_opt(_n)\n #define\t__out_bcount_part(_n, _l)\ndiff --git a/drivers/net/sfc/base/efx_rx.c b/drivers/net/sfc/base/efx_rx.c\nindex dfd3974da..bb0c144d7 100644\n--- a/drivers/net/sfc/base/efx_rx.c\n+++ b/drivers/net/sfc/base/efx_rx.c\n@@ -298,13 +298,12 @@ efx_rx_scatter_enable(\n efx_rx_scale_hash_flags_get(\n \t__in\t\t\t\t\tefx_nic_t *enp,\n \t__in\t\t\t\t\tefx_rx_hash_alg_t hash_alg,\n-\t__inout_ecount(EFX_RX_HASH_NFLAGS)\tunsigned int *flagsp,\n+\t__out_ecount_part(max_nflags, *nflagsp)\tunsigned int *flagsp,\n+\t__in\t\t\t\t\tunsigned int max_nflags,\n \t__out\t\t\t\t\tunsigned int *nflagsp)\n {\n \tefx_nic_cfg_t *encp = &enp->en_nic_cfg;\n-\tboolean_t l4;\n-\tboolean_t additional_modes;\n-\tunsigned int *entryp = flagsp;\n+\tunsigned int nflags = 0;\n \tefx_rc_t rc;\n \n \tif (flagsp == NULL || nflagsp == NULL) {\n@@ -313,56 +312,90 @@ efx_rx_scale_hash_flags_get(\n \t}\n \n \tif ((encp->enc_rx_scale_hash_alg_mask & (1U << hash_alg)) == 0) {\n-\t\t*nflagsp = 0;\n-\t\treturn 0;\n+\t\tnflags = 0;\n+\t\tgoto done;\n \t}\n \n-\tl4 = encp->enc_rx_scale_l4_hash_supported;\n-\tadditional_modes = encp->enc_rx_scale_additional_modes_supported;\n-\n-#define\tLIST_FLAGS(_entryp, _class, _l4_hashing, _additional_modes)\t\\\n-\tdo {\t\t\t\t\t\t\t\t\\\n-\t\tif (_l4_hashing) {\t\t\t\t\t\\\n-\t\t\t*(_entryp++) = EFX_RX_HASH(_class, 4TUPLE);\t\\\n-\t\t\t\t\t\t\t\t\t\\\n-\t\t\tif (_additional_modes) {\t\t\t\\\n-\t\t\t\t*(_entryp++) =\t\t\t\t\\\n-\t\t\t\t    EFX_RX_HASH(_class, 2TUPLE_DST);\t\\\n-\t\t\t\t*(_entryp++) =\t\t\t\t\\\n-\t\t\t\t    EFX_RX_HASH(_class, 2TUPLE_SRC);\t\\\n-\t\t\t}\t\t\t\t\t\t\\\n-\t\t}\t\t\t\t\t\t\t\\\n-\t\t\t\t\t\t\t\t\t\\\n-\t\t*(_entryp++) = EFX_RX_HASH(_class, 2TUPLE);\t\t\\\n-\t\t\t\t\t\t\t\t\t\\\n-\t\tif (_additional_modes) {\t\t\t\t\\\n-\t\t\t*(_entryp++) = EFX_RX_HASH(_class, 1TUPLE_DST);\t\\\n-\t\t\t*(_entryp++) = EFX_RX_HASH(_class, 1TUPLE_SRC);\t\\\n-\t\t}\t\t\t\t\t\t\t\\\n-\t\t\t\t\t\t\t\t\t\\\n-\t\t*(_entryp++) = EFX_RX_HASH(_class, DISABLE);\t\t\\\n-\t\t\t\t\t\t\t\t\t\\\n-\t\t_NOTE(CONSTANTCONDITION)\t\t\t\t\\\n+\t/* Helper to add flags word to flags array without buffer overflow */\n+#define\tINSERT_FLAGS(_flags)\t\t\t\\\n+\tdo {\t\t\t\t\t\\\n+\t\tif (nflags >= max_nflags) {\t\\\n+\t\t\trc = E2BIG;\t\t\\\n+\t\t\tgoto fail2;\t\t\\\n+\t\t}\t\t\t\t\\\n+\t\t*(flagsp + nflags) = (_flags);\t\\\n+\t\tnflags++;\t\t\t\\\n+\t\t\t\t\t\t\\\n+\t\t_NOTE(CONSTANTCONDITION)\t\\\n \t} while (B_FALSE)\n \n-\tLIST_FLAGS(entryp, IPV4_TCP, l4, additional_modes);\n-\tLIST_FLAGS(entryp, IPV6_TCP, l4, additional_modes);\n+\tif (encp->enc_rx_scale_l4_hash_supported != B_FALSE) {\n+\t\tINSERT_FLAGS(EFX_RX_HASH(IPV4_TCP, 4TUPLE));\n+\t\tINSERT_FLAGS(EFX_RX_HASH(IPV6_TCP, 4TUPLE));\n+\t}\n+\n+\tif ((encp->enc_rx_scale_l4_hash_supported != B_FALSE) &&\n+\t    (encp->enc_rx_scale_additional_modes_supported != B_FALSE)) {\n+\t\tINSERT_FLAGS(EFX_RX_HASH(IPV4_TCP, 2TUPLE_DST));\n+\t\tINSERT_FLAGS(EFX_RX_HASH(IPV4_TCP, 2TUPLE_SRC));\n+\n+\t\tINSERT_FLAGS(EFX_RX_HASH(IPV6_TCP, 2TUPLE_DST));\n+\t\tINSERT_FLAGS(EFX_RX_HASH(IPV6_TCP, 2TUPLE_SRC));\n \n-\tif (additional_modes) {\n-\t\tLIST_FLAGS(entryp, IPV4_UDP, l4, additional_modes);\n-\t\tLIST_FLAGS(entryp, IPV6_UDP, l4, additional_modes);\n+\t\tINSERT_FLAGS(EFX_RX_HASH(IPV4_UDP, 4TUPLE));\n+\t\tINSERT_FLAGS(EFX_RX_HASH(IPV4_UDP, 2TUPLE_DST));\n+\t\tINSERT_FLAGS(EFX_RX_HASH(IPV4_UDP, 2TUPLE_SRC));\n+\n+\t\tINSERT_FLAGS(EFX_RX_HASH(IPV6_UDP, 4TUPLE));\n+\t\tINSERT_FLAGS(EFX_RX_HASH(IPV6_UDP, 2TUPLE_DST));\n+\t\tINSERT_FLAGS(EFX_RX_HASH(IPV6_UDP, 2TUPLE_SRC));\n+\t}\n+\n+\tINSERT_FLAGS(EFX_RX_HASH(IPV4_TCP, 2TUPLE));\n+\tINSERT_FLAGS(EFX_RX_HASH(IPV6_TCP, 2TUPLE));\n+\n+\tINSERT_FLAGS(EFX_RX_HASH(IPV4, 2TUPLE));\n+\tINSERT_FLAGS(EFX_RX_HASH(IPV6, 2TUPLE));\n+\n+\tif (encp->enc_rx_scale_additional_modes_supported != B_FALSE) {\n+\t\tINSERT_FLAGS(EFX_RX_HASH(IPV4_TCP, 1TUPLE_DST));\n+\t\tINSERT_FLAGS(EFX_RX_HASH(IPV4_TCP, 1TUPLE_SRC));\n+\n+\t\tINSERT_FLAGS(EFX_RX_HASH(IPV6_TCP, 1TUPLE_DST));\n+\t\tINSERT_FLAGS(EFX_RX_HASH(IPV6_TCP, 1TUPLE_SRC));\n+\n+\t\tINSERT_FLAGS(EFX_RX_HASH(IPV4_UDP, 2TUPLE));\n+\t\tINSERT_FLAGS(EFX_RX_HASH(IPV4_UDP, 1TUPLE_DST));\n+\t\tINSERT_FLAGS(EFX_RX_HASH(IPV4_UDP, 1TUPLE_SRC));\n+\n+\t\tINSERT_FLAGS(EFX_RX_HASH(IPV6_UDP, 2TUPLE));\n+\t\tINSERT_FLAGS(EFX_RX_HASH(IPV6_UDP, 1TUPLE_DST));\n+\t\tINSERT_FLAGS(EFX_RX_HASH(IPV6_UDP, 1TUPLE_SRC));\n+\n+\t\tINSERT_FLAGS(EFX_RX_HASH(IPV4, 1TUPLE_DST));\n+\t\tINSERT_FLAGS(EFX_RX_HASH(IPV4, 1TUPLE_SRC));\n+\n+\t\tINSERT_FLAGS(EFX_RX_HASH(IPV6, 1TUPLE_DST));\n+\t\tINSERT_FLAGS(EFX_RX_HASH(IPV6, 1TUPLE_SRC));\n \t}\n \n-\tLIST_FLAGS(entryp, IPV4, B_FALSE, additional_modes);\n-\tLIST_FLAGS(entryp, IPV6, B_FALSE, additional_modes);\n+\tINSERT_FLAGS(EFX_RX_HASH(IPV4_TCP, DISABLE));\n+\tINSERT_FLAGS(EFX_RX_HASH(IPV6_TCP, DISABLE));\n+\n+\tINSERT_FLAGS(EFX_RX_HASH(IPV4_UDP, DISABLE));\n+\tINSERT_FLAGS(EFX_RX_HASH(IPV6_UDP, DISABLE));\n \n-#undef LIST_FLAGS\n+\tINSERT_FLAGS(EFX_RX_HASH(IPV4, DISABLE));\n+\tINSERT_FLAGS(EFX_RX_HASH(IPV6, DISABLE));\n \n-\t*nflagsp = (unsigned int)(entryp - flagsp);\n-\tEFSYS_ASSERT3U(*nflagsp, <=, EFX_RX_HASH_NFLAGS);\n+#undef INSERT_FLAGS\n \n+done:\n+\t*nflagsp = nflags;\n \treturn (0);\n \n+fail2:\n+\tEFSYS_PROBE(fail2);\n fail1:\n \tEFSYS_PROBE1(fail1, efx_rc_t, rc);\n \n@@ -548,7 +581,8 @@ efx_rx_scale_mode_set(\n \t/*\n \t * Get the list of supported hash flags and sanitise the input.\n \t */\n-\trc = efx_rx_scale_hash_flags_get(enp, alg, type_flags, &type_nflags);\n+\trc = efx_rx_scale_hash_flags_get(enp, alg, type_flags,\n+\t\t\t\t    EFX_ARRAY_SIZE(type_flags), &type_nflags);\n \tif (rc != 0)\n \t\tgoto fail2;\n \ndiff --git a/drivers/net/sfc/sfc_rx.c b/drivers/net/sfc/sfc_rx.c\nindex d8503e201..68d5594ba 100644\n--- a/drivers/net/sfc/sfc_rx.c\n+++ b/drivers/net/sfc/sfc_rx.c\n@@ -1200,7 +1200,7 @@ sfc_rx_hash_init(struct sfc_adapter *sa)\n \t\treturn EINVAL;\n \n \trc = efx_rx_scale_hash_flags_get(sa->nic, alg, flags_supp,\n-\t\t\t\t\t &nb_flags_supp);\n+\t\t\t\t\t RTE_DIM(flags_supp), &nb_flags_supp);\n \tif (rc != 0)\n \t\treturn rc;\n \n",
    "prefixes": [
        "32/37"
    ]
}