get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 1090464,
    "url": "http://patchwork.ozlabs.org/api/patches/1090464/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20190424122055.27896-6-alice.michael@intel.com/",
    "project": {
        "id": 46,
        "url": "http://patchwork.ozlabs.org/api/projects/46/?format=api",
        "name": "Intel Wired Ethernet development",
        "link_name": "intel-wired-lan",
        "list_id": "intel-wired-lan.osuosl.org",
        "list_email": "intel-wired-lan@osuosl.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": "",
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<20190424122055.27896-6-alice.michael@intel.com>",
    "list_archive_url": null,
    "date": "2019-04-24T12:20:51",
    "name": "[next,S5,06/10] i40e: add input validation for virtchnl handlers",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "bcefe8537cf27ba93c0a5f9124976536ee29cd12",
    "submitter": {
        "id": 71123,
        "url": "http://patchwork.ozlabs.org/api/people/71123/?format=api",
        "name": "Michael, Alice",
        "email": "alice.michael@intel.com"
    },
    "delegate": {
        "id": 68,
        "url": "http://patchwork.ozlabs.org/api/users/68/?format=api",
        "username": "jtkirshe",
        "first_name": "Jeff",
        "last_name": "Kirsher",
        "email": "jeffrey.t.kirsher@intel.com"
    },
    "mbox": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20190424122055.27896-6-alice.michael@intel.com/mbox/",
    "series": [
        {
            "id": 104485,
            "url": "http://patchwork.ozlabs.org/api/series/104485/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/list/?series=104485",
            "date": "2019-04-24T12:20:48",
            "name": "[next,S5,01/10] i40e: let untrusted VF to create up to 16 VLANs",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/104485/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/1090464/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/1090464/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<intel-wired-lan-bounces@osuosl.org>",
        "X-Original-To": [
            "incoming@patchwork.ozlabs.org",
            "intel-wired-lan@lists.osuosl.org"
        ],
        "Delivered-To": [
            "patchwork-incoming@bilbo.ozlabs.org",
            "intel-wired-lan@lists.osuosl.org"
        ],
        "Authentication-Results": [
            "ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=osuosl.org\n\t(client-ip=140.211.166.136; helo=silver.osuosl.org;\n\tenvelope-from=intel-wired-lan-bounces@osuosl.org;\n\treceiver=<UNKNOWN>)",
            "ozlabs.org;\n\tdmarc=fail (p=none dis=none) header.from=intel.com"
        ],
        "Received": [
            "from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 44qBwF0ZJ9z9s4V\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 25 Apr 2019 06:38:05 +1000 (AEST)",
            "from localhost (localhost [127.0.0.1])\n\tby silver.osuosl.org (Postfix) with ESMTP id A75D330B46;\n\tWed, 24 Apr 2019 20:38:03 +0000 (UTC)",
            "from silver.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id XCS3h9Kw+o2f; Wed, 24 Apr 2019 20:37:59 +0000 (UTC)",
            "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby silver.osuosl.org (Postfix) with ESMTP id 7FD9730AA4;\n\tWed, 24 Apr 2019 20:37:59 +0000 (UTC)",
            "from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137])\n\tby ash.osuosl.org (Postfix) with ESMTP id 3BC771BF3C0\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tWed, 24 Apr 2019 20:37:58 +0000 (UTC)",
            "from localhost (localhost [127.0.0.1])\n\tby fraxinus.osuosl.org (Postfix) with ESMTP id 343DB86190\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tWed, 24 Apr 2019 20:37:58 +0000 (UTC)",
            "from fraxinus.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id D8tztWpStkuU for <intel-wired-lan@lists.osuosl.org>;\n\tWed, 24 Apr 2019 20:37:57 +0000 (UTC)",
            "from mga01.intel.com (mga01.intel.com [192.55.52.88])\n\tby fraxinus.osuosl.org (Postfix) with ESMTPS id 35F5486203\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tWed, 24 Apr 2019 20:37:57 +0000 (UTC)",
            "from fmsmga002.fm.intel.com ([10.253.24.26])\n\tby fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t24 Apr 2019 13:36:55 -0700",
            "from alicemic-2.jf.intel.com ([10.166.16.121])\n\tby fmsmga002.fm.intel.com with ESMTP; 24 Apr 2019 13:36:54 -0700"
        ],
        "X-Virus-Scanned": [
            "amavisd-new at osuosl.org",
            "amavisd-new at osuosl.org"
        ],
        "X-Greylist": "domain auto-whitelisted by SQLgrey-1.7.6",
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.60,390,1549958400\"; d=\"scan'208\";a=\"164544017\"",
        "From": "Alice Michael <alice.michael@intel.com>",
        "To": "alice.michael@intel.com,\n\tintel-wired-lan@lists.osuosl.org",
        "Date": "Wed, 24 Apr 2019 05:20:51 -0700",
        "Message-Id": "<20190424122055.27896-6-alice.michael@intel.com>",
        "X-Mailer": "git-send-email 2.19.2",
        "In-Reply-To": "<20190424122055.27896-1-alice.michael@intel.com>",
        "References": "<20190424122055.27896-1-alice.michael@intel.com>",
        "MIME-Version": "1.0",
        "Subject": "[Intel-wired-lan] [next PATCH S5 06/10] i40e: add input validation\n\tfor virtchnl handlers",
        "X-BeenThere": "intel-wired-lan@osuosl.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "Intel Wired Ethernet Linux Kernel Driver Development\n\t<intel-wired-lan.osuosl.org>",
        "List-Unsubscribe": "<https://lists.osuosl.org/mailman/options/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@osuosl.org?subject=unsubscribe>",
        "List-Archive": "<http://lists.osuosl.org/pipermail/intel-wired-lan/>",
        "List-Post": "<mailto:intel-wired-lan@osuosl.org>",
        "List-Help": "<mailto:intel-wired-lan-request@osuosl.org?subject=help>",
        "List-Subscribe": "<https://lists.osuosl.org/mailman/listinfo/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@osuosl.org?subject=subscribe>",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Errors-To": "intel-wired-lan-bounces@osuosl.org",
        "Sender": "\"Intel-wired-lan\" <intel-wired-lan-bounces@osuosl.org>"
    },
    "content": "From: Sergey Nemov <sergey.nemov@intel.com>\n\nChange some data to unsigned int instead of integer when we compare.\n\nCheck LUT values in VIRTCHNL_OP_CONFIG_RSS_LUT handler.\n\nAlso enhance error/warning messages to print the real values of\nI40E_MAX_VF_QUEUES, I40E_MAX_VF_VSI and I40E_DEFAULT_QUEUES_PER_VF\ninstead of plain text.\n\nRefactor code to comply with 'check first then assign' policy.\n\nRemove duplicate checks for VIRTCHNL_OP_CONFIG_RSS_KEY and\nVIRTCHNL_OP_CONFIG_RSS_LUT opcodes in i40e_vc_process_vf_msg(). We have\nthe very same checks inside the handlers already.\n\nSigned-off-by: Sergey Nemov <sergey.nemov@intel.com>\n---\n .../ethernet/intel/i40e/i40e_virtchnl_pf.c    | 74 ++++++++-----------\n 1 file changed, 31 insertions(+), 43 deletions(-)",
    "diff": "diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c\nindex 4061da6c9dcb..4f4521d39725 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c\n+++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c\n@@ -470,14 +470,15 @@ static int i40e_config_iwarp_qvlist(struct i40e_vf *vf,\n \t\tqv_info = &qvlist_info->qv_info[i];\n \t\tif (!qv_info)\n \t\t\tcontinue;\n-\t\tv_idx = qv_info->v_idx;\n \n \t\t/* Validate vector id belongs to this vf */\n-\t\tif (!i40e_vc_isvalid_vector_id(vf, v_idx)) {\n+\t\tif (!i40e_vc_isvalid_vector_id(vf, qv_info->v_idx)) {\n \t\t\tret = -EINVAL;\n \t\t\tgoto err_free;\n \t\t}\n \n+\t\tv_idx = qv_info->v_idx;\n+\n \t\tvf->qvlist_info->qv_info[i] = *qv_info;\n \n \t\treg_idx = ((msix_vf - 1) * vf->vf_id) + (v_idx - 1);\n@@ -2327,7 +2328,6 @@ static int i40e_vc_enable_queues_msg(struct i40e_vf *vf, u8 *msg)\n \tstruct virtchnl_queue_select *vqs =\n \t    (struct virtchnl_queue_select *)msg;\n \tstruct i40e_pf *pf = vf->pf;\n-\tu16 vsi_id = vqs->vsi_id;\n \ti40e_status aq_ret = 0;\n \tint i;\n \n@@ -2336,7 +2336,7 @@ static int i40e_vc_enable_queues_msg(struct i40e_vf *vf, u8 *msg)\n \t\tgoto error_param;\n \t}\n \n-\tif (!i40e_vc_isvalid_vsi_id(vf, vsi_id)) {\n+\tif (!i40e_vc_isvalid_vsi_id(vf, vqs->vsi_id)) {\n \t\taq_ret = I40E_ERR_PARAM;\n \t\tgoto error_param;\n \t}\n@@ -2436,18 +2436,14 @@ static int i40e_vc_request_queues_msg(struct i40e_vf *vf, u8 *msg)\n {\n \tstruct virtchnl_vf_res_request *vfres =\n \t\t(struct virtchnl_vf_res_request *)msg;\n-\tint req_pairs = vfres->num_queue_pairs;\n-\tint cur_pairs = vf->num_queue_pairs;\n+\tu16 req_pairs = vfres->num_queue_pairs;\n+\tu8 cur_pairs = vf->num_queue_pairs;\n \tstruct i40e_pf *pf = vf->pf;\n \n \tif (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states))\n \t\treturn -EINVAL;\n \n-\tif (req_pairs <= 0) {\n-\t\tdev_err(&pf->pdev->dev,\n-\t\t\t\"VF %d tried to request %d queues.  Ignoring.\\n\",\n-\t\t\tvf->vf_id, req_pairs);\n-\t} else if (req_pairs > I40E_MAX_VF_QUEUES) {\n+\tif (req_pairs > I40E_MAX_VF_QUEUES) {\n \t\tdev_err(&pf->pdev->dev,\n \t\t\t\"VF %d tried to request more than %d queues.\\n\",\n \t\t\tvf->vf_id,\n@@ -2596,12 +2592,11 @@ static int i40e_vc_add_mac_addr_msg(struct i40e_vf *vf, u8 *msg)\n \t    (struct virtchnl_ether_addr_list *)msg;\n \tstruct i40e_pf *pf = vf->pf;\n \tstruct i40e_vsi *vsi = NULL;\n-\tu16 vsi_id = al->vsi_id;\n \ti40e_status ret = 0;\n \tint i;\n \n \tif (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states) ||\n-\t    !i40e_vc_isvalid_vsi_id(vf, vsi_id)) {\n+\t    !i40e_vc_isvalid_vsi_id(vf, al->vsi_id)) {\n \t\tret = I40E_ERR_PARAM;\n \t\tgoto error_param;\n \t}\n@@ -2666,12 +2661,11 @@ static int i40e_vc_del_mac_addr_msg(struct i40e_vf *vf, u8 *msg)\n \t    (struct virtchnl_ether_addr_list *)msg;\n \tstruct i40e_pf *pf = vf->pf;\n \tstruct i40e_vsi *vsi = NULL;\n-\tu16 vsi_id = al->vsi_id;\n \ti40e_status ret = 0;\n \tint i;\n \n \tif (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states) ||\n-\t    !i40e_vc_isvalid_vsi_id(vf, vsi_id)) {\n+\t    !i40e_vc_isvalid_vsi_id(vf, al->vsi_id)) {\n \t\tret = I40E_ERR_PARAM;\n \t\tgoto error_param;\n \t}\n@@ -2735,7 +2729,6 @@ static int i40e_vc_add_vlan_msg(struct i40e_vf *vf, u8 *msg)\n \t    (struct virtchnl_vlan_filter_list *)msg;\n \tstruct i40e_pf *pf = vf->pf;\n \tstruct i40e_vsi *vsi = NULL;\n-\tu16 vsi_id = vfl->vsi_id;\n \ti40e_status aq_ret = 0;\n \tint i;\n \n@@ -2746,7 +2739,7 @@ static int i40e_vc_add_vlan_msg(struct i40e_vf *vf, u8 *msg)\n \t\tgoto error_param;\n \t}\n \tif (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states) ||\n-\t    !i40e_vc_isvalid_vsi_id(vf, vsi_id)) {\n+\t    !i40e_vc_isvalid_vsi_id(vf, vfl->vsi_id)) {\n \t\taq_ret = I40E_ERR_PARAM;\n \t\tgoto error_param;\n \t}\n@@ -2807,12 +2800,11 @@ static int i40e_vc_remove_vlan_msg(struct i40e_vf *vf, u8 *msg)\n \t    (struct virtchnl_vlan_filter_list *)msg;\n \tstruct i40e_pf *pf = vf->pf;\n \tstruct i40e_vsi *vsi = NULL;\n-\tu16 vsi_id = vfl->vsi_id;\n \ti40e_status aq_ret = 0;\n \tint i;\n \n \tif (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states) ||\n-\t    !i40e_vc_isvalid_vsi_id(vf, vsi_id)) {\n+\t    !i40e_vc_isvalid_vsi_id(vf, vfl->vsi_id)) {\n \t\taq_ret = I40E_ERR_PARAM;\n \t\tgoto error_param;\n \t}\n@@ -2929,11 +2921,10 @@ static int i40e_vc_config_rss_key(struct i40e_vf *vf, u8 *msg)\n \t\t(struct virtchnl_rss_key *)msg;\n \tstruct i40e_pf *pf = vf->pf;\n \tstruct i40e_vsi *vsi = NULL;\n-\tu16 vsi_id = vrk->vsi_id;\n \ti40e_status aq_ret = 0;\n \n \tif (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states) ||\n-\t    !i40e_vc_isvalid_vsi_id(vf, vsi_id) ||\n+\t    !i40e_vc_isvalid_vsi_id(vf, vrk->vsi_id) ||\n \t    (vrk->key_len != I40E_HKEY_ARRAY_SIZE)) {\n \t\taq_ret = I40E_ERR_PARAM;\n \t\tgoto err;\n@@ -2960,16 +2951,22 @@ static int i40e_vc_config_rss_lut(struct i40e_vf *vf, u8 *msg)\n \t\t(struct virtchnl_rss_lut *)msg;\n \tstruct i40e_pf *pf = vf->pf;\n \tstruct i40e_vsi *vsi = NULL;\n-\tu16 vsi_id = vrl->vsi_id;\n \ti40e_status aq_ret = 0;\n+\tu16 i;\n \n \tif (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states) ||\n-\t    !i40e_vc_isvalid_vsi_id(vf, vsi_id) ||\n+\t    !i40e_vc_isvalid_vsi_id(vf, vrl->vsi_id) ||\n \t    (vrl->lut_entries != I40E_VF_HLUT_ARRAY_SIZE)) {\n \t\taq_ret = I40E_ERR_PARAM;\n \t\tgoto err;\n \t}\n \n+\tfor (i = 0; i < vrl->lut_entries; i++)\n+\t\tif (vrl->lut[i] >= vf->num_queue_pairs) {\n+\t\t\taq_ret = I40E_ERR_PARAM;\n+\t\t\tgoto err;\n+\t\t}\n+\n \tvsi = pf->vsi[vf->lan_vsi_idx];\n \taq_ret = i40e_config_rss(vsi, NULL, vrl->lut, I40E_VF_HLUT_ARRAY_SIZE);\n \t/* send the response to the VF */\n@@ -3050,14 +3047,15 @@ static int i40e_vc_set_rss_hena(struct i40e_vf *vf, u8 *msg)\n  **/\n static int i40e_vc_enable_vlan_stripping(struct i40e_vf *vf, u8 *msg)\n {\n-\tstruct i40e_vsi *vsi = vf->pf->vsi[vf->lan_vsi_idx];\n \ti40e_status aq_ret = 0;\n+\tstruct i40e_vsi *vsi;\n \n \tif (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) {\n \t\taq_ret = I40E_ERR_PARAM;\n \t\tgoto err;\n \t}\n \n+\tvsi = vf->pf->vsi[vf->lan_vsi_idx];\n \ti40e_vlan_stripping_enable(vsi);\n \n \t/* send the response to the VF */\n@@ -3075,14 +3073,15 @@ static int i40e_vc_enable_vlan_stripping(struct i40e_vf *vf, u8 *msg)\n  **/\n static int i40e_vc_disable_vlan_stripping(struct i40e_vf *vf, u8 *msg)\n {\n-\tstruct i40e_vsi *vsi = vf->pf->vsi[vf->lan_vsi_idx];\n \ti40e_status aq_ret = 0;\n+\tstruct i40e_vsi *vsi;\n \n \tif (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) {\n \t\taq_ret = I40E_ERR_PARAM;\n \t\tgoto err;\n \t}\n \n+\tvsi = vf->pf->vsi[vf->lan_vsi_idx];\n \ti40e_vlan_stripping_disable(vsi);\n \n \t/* send the response to the VF */\n@@ -3540,8 +3539,9 @@ static int i40e_vc_add_qch_msg(struct i40e_vf *vf, u8 *msg)\n \t\t(struct virtchnl_tc_info *)msg;\n \tstruct i40e_pf *pf = vf->pf;\n \tstruct i40e_link_status *ls = &pf->hw.phy.link_info;\n-\tint i, adq_request_qps = 0, speed = 0;\n+\tint i, adq_request_qps = 0;\n \ti40e_status aq_ret = 0;\n+\tu64 speed = 0;\n \n \tif (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) {\n \t\taq_ret = I40E_ERR_PARAM;\n@@ -3567,8 +3567,8 @@ static int i40e_vc_add_qch_msg(struct i40e_vf *vf, u8 *msg)\n \t/* max number of traffic classes for VF currently capped at 4 */\n \tif (!tci->num_tc || tci->num_tc > I40E_MAX_VF_VSI) {\n \t\tdev_err(&pf->pdev->dev,\n-\t\t\t\"VF %d trying to set %u TCs, valid range 1-4 TCs per VF\\n\",\n-\t\t\tvf->vf_id, tci->num_tc);\n+\t\t\t\"VF %d trying to set %u TCs, valid range 1-%u TCs per VF\\n\",\n+\t\t\tvf->vf_id, tci->num_tc, I40E_MAX_VF_VSI);\n \t\taq_ret = I40E_ERR_PARAM;\n \t\tgoto err;\n \t}\n@@ -3578,8 +3578,9 @@ static int i40e_vc_add_qch_msg(struct i40e_vf *vf, u8 *msg)\n \t\tif (!tci->list[i].count ||\n \t\t    tci->list[i].count > I40E_DEFAULT_QUEUES_PER_VF) {\n \t\t\tdev_err(&pf->pdev->dev,\n-\t\t\t\t\"VF %d: TC %d trying to set %u queues, valid range 1-4 queues per TC\\n\",\n-\t\t\t\tvf->vf_id, i, tci->list[i].count);\n+\t\t\t\t\"VF %d: TC %d trying to set %u queues, valid range 1-%u queues per TC\\n\",\n+\t\t\t\tvf->vf_id, i, tci->list[i].count,\n+\t\t\t\tI40E_DEFAULT_QUEUES_PER_VF);\n \t\t\taq_ret = I40E_ERR_PARAM;\n \t\t\tgoto err;\n \t\t}\n@@ -3739,19 +3740,6 @@ int i40e_vc_process_vf_msg(struct i40e_pf *pf, s16 vf_id, u32 v_opcode,\n \t/* perform basic checks on the msg */\n \tret = virtchnl_vc_validate_vf_msg(&vf->vf_ver, v_opcode, msg, msglen);\n \n-\t/* perform additional checks specific to this driver */\n-\tif (v_opcode == VIRTCHNL_OP_CONFIG_RSS_KEY) {\n-\t\tstruct virtchnl_rss_key *vrk = (struct virtchnl_rss_key *)msg;\n-\n-\t\tif (vrk->key_len != I40E_HKEY_ARRAY_SIZE)\n-\t\t\tret = -EINVAL;\n-\t} else if (v_opcode == VIRTCHNL_OP_CONFIG_RSS_LUT) {\n-\t\tstruct virtchnl_rss_lut *vrl = (struct virtchnl_rss_lut *)msg;\n-\n-\t\tif (vrl->lut_entries != I40E_VF_HLUT_ARRAY_SIZE)\n-\t\t\tret = -EINVAL;\n-\t}\n-\n \tif (ret) {\n \t\ti40e_vc_send_resp_to_vf(vf, v_opcode, I40E_ERR_PARAM);\n \t\tdev_err(&pf->pdev->dev, \"Invalid message from VF %d, opcode %d, len %d\\n\",\n",
    "prefixes": [
        "next",
        "S5",
        "06/10"
    ]
}