Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/991019/?format=api
{ "id": 991019, "url": "http://patchwork.ozlabs.org/api/patches/991019/?format=api", "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20181030175047.18874-4-jeffrey.t.kirsher@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": "<20181030175047.18874-4-jeffrey.t.kirsher@intel.com>", "list_archive_url": null, "date": "2018-10-30T17:50:45", "name": "[next,S97,v2,4/6] i40e: Protect access to vf control methods", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "470fcbc59e64e3c0a4561a24abb286195a876efd", "submitter": { "id": 473, "url": "http://patchwork.ozlabs.org/api/people/473/?format=api", "name": "Kirsher, Jeffrey T", "email": "jeffrey.t.kirsher@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/20181030175047.18874-4-jeffrey.t.kirsher@intel.com/mbox/", "series": [ { "id": 73269, "url": "http://patchwork.ozlabs.org/api/series/73269/?format=api", "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/list/?series=73269", "date": "2018-10-30T17:50:43", "name": "[next,S97,v2,1/6] i40e: Use a local variable for readability", "version": 2, "mbox": "http://patchwork.ozlabs.org/series/73269/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/991019/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/991019/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 42kzXg1zKwz9s9G\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 31 Oct 2018 04:50:59 +1100 (AEDT)", "from localhost (localhost [127.0.0.1])\n\tby silver.osuosl.org (Postfix) with ESMTP id AB4312EE62;\n\tTue, 30 Oct 2018 17:50:57 +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 uYF4nvyMINsG; Tue, 30 Oct 2018 17:50:55 +0000 (UTC)", "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby silver.osuosl.org (Postfix) with ESMTP id 5312E2EE58;\n\tTue, 30 Oct 2018 17:50:55 +0000 (UTC)", "from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138])\n\tby ash.osuosl.org (Postfix) with ESMTP id 66BAE1BF29A\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tTue, 30 Oct 2018 17:50:51 +0000 (UTC)", "from localhost (localhost [127.0.0.1])\n\tby whitealder.osuosl.org (Postfix) with ESMTP id 6362C879F3\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tTue, 30 Oct 2018 17:50:51 +0000 (UTC)", "from whitealder.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id TnammtsWF6Fd for <intel-wired-lan@lists.osuosl.org>;\n\tTue, 30 Oct 2018 17:50:50 +0000 (UTC)", "from mga01.intel.com (mga01.intel.com [192.55.52.88])\n\tby whitealder.osuosl.org (Postfix) with ESMTPS id DFBFA879FA\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tTue, 30 Oct 2018 17:50:49 +0000 (UTC)", "from fmsmga008.fm.intel.com ([10.253.24.58])\n\tby fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t30 Oct 2018 10:50:49 -0700", "from jtkirshe-desk1.jf.intel.com ([134.134.177.96])\n\tby fmsmga008.fm.intel.com with ESMTP; 30 Oct 2018 10:50:49 -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.54,445,1534834800\"; d=\"scan'208\";a=\"82759442\"", "From": "Jeff Kirsher <jeffrey.t.kirsher@intel.com>", "To": "intel-wired-lan@lists.osuosl.org", "Date": "Tue, 30 Oct 2018 10:50:45 -0700", "Message-Id": "<20181030175047.18874-4-jeffrey.t.kirsher@intel.com>", "X-Mailer": "git-send-email 2.17.2", "In-Reply-To": "<20181030175047.18874-1-jeffrey.t.kirsher@intel.com>", "References": "<20181030175047.18874-1-jeffrey.t.kirsher@intel.com>", "Subject": "[Intel-wired-lan] [next S97 v2 4/6] i40e: Protect access to vf\n\tcontrol methods", "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>", "MIME-Version": "1.0", "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: Jan Sokolowski <jan.sokolowski@intel.com>\n\nA scenario has been found in which simultaneous\naddition/removal and modification of VF's might cause\nunstable behaviour, up to and including kernel panics.\n\nProtect the methods that create/modify/destroy VF's\nby locking them behind an atomically set bit in PF status\nbitfield.\n\nSigned-off-by: Jan Sokolowski <jan.sokolowski@intel.com>\n---\n drivers/net/ethernet/intel/i40e/i40e.h | 1 +\n .../ethernet/intel/i40e/i40e_virtchnl_pf.c | 64 +++++++++++++++++--\n 2 files changed, 60 insertions(+), 5 deletions(-)", "diff": "diff --git a/drivers/net/ethernet/intel/i40e/i40e.h b/drivers/net/ethernet/intel/i40e/i40e.h\nindex 11f0987f16c7..f575b03bc3ed 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e.h\n+++ b/drivers/net/ethernet/intel/i40e/i40e.h\n@@ -147,6 +147,7 @@ enum i40e_state_t {\n \t__I40E_CLIENT_SERVICE_REQUESTED,\n \t__I40E_CLIENT_L2_CHANGE,\n \t__I40E_CLIENT_RESET,\n+\t__I40E_VIRTCHNL_OP_PENDING,\n \t/* This must be last as it determines the size of the BITMAP */\n \t__I40E_STATE_SIZE__,\n };\ndiff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c\nindex ac5698ed0b11..8e0a247e7e5a 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c\n+++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c\n@@ -1675,13 +1675,20 @@ static int i40e_pci_sriov_enable(struct pci_dev *pdev, int num_vfs)\n int i40e_pci_sriov_configure(struct pci_dev *pdev, int num_vfs)\n {\n \tstruct i40e_pf *pf = pci_get_drvdata(pdev);\n+\tint ret = 0;\n+\n+\tif (test_and_set_bit(__I40E_VIRTCHNL_OP_PENDING, pf->state)) {\n+\t\tdev_warn(&pdev->dev, \"Unable to configure VFs, other operation is pending.\\n\");\n+\t\treturn -EAGAIN;\n+\t}\n \n \tif (num_vfs) {\n \t\tif (!(pf->flags & I40E_FLAG_VEB_MODE_ENABLED)) {\n \t\t\tpf->flags |= I40E_FLAG_VEB_MODE_ENABLED;\n \t\t\ti40e_do_reset_safe(pf, I40E_PF_RESET_FLAG);\n \t\t}\n-\t\treturn i40e_pci_sriov_enable(pdev, num_vfs);\n+\t\tret = i40e_pci_sriov_enable(pdev, num_vfs);\n+\t\tgoto sriov_configure_out;\n \t}\n \n \tif (!pci_vfs_assigned(pf->pdev)) {\n@@ -1690,9 +1697,12 @@ int i40e_pci_sriov_configure(struct pci_dev *pdev, int num_vfs)\n \t\ti40e_do_reset_safe(pf, I40E_PF_RESET_FLAG);\n \t} else {\n \t\tdev_warn(&pdev->dev, \"Unable to free VFs because some are assigned to VMs.\\n\");\n-\t\treturn -EINVAL;\n+\t\tret = -EINVAL;\n+\t\tgoto sriov_configure_out;\n \t}\n-\treturn 0;\n+sriov_configure_out:\n+\tclear_bit(__I40E_VIRTCHNL_OP_PENDING, pf->state);\n+\treturn ret;\n }\n \n /***********************virtual channel routines******************/\n@@ -3893,6 +3903,11 @@ int i40e_ndo_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac)\n \t\tgoto error_param;\n \t}\n \n+\tif (test_and_set_bit(__I40E_VIRTCHNL_OP_PENDING, pf->state)) {\n+\t\tdev_warn(&pf->pdev->dev, \"Unable to configure VFs, other operation is pending.\\n\");\n+\t\treturn -EAGAIN;\n+\t}\n+\n \tif (is_multicast_ether_addr(mac)) {\n \t\tdev_err(&pf->pdev->dev,\n \t\t\t\"Invalid Ethernet address %pM for VF %d\\n\", mac, vf_id);\n@@ -3941,6 +3956,7 @@ int i40e_ndo_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac)\n \tdev_info(&pf->pdev->dev, \"Bring down and up the VF interface to make this change effective.\\n\");\n \n error_param:\n+\tclear_bit(__I40E_VIRTCHNL_OP_PENDING, pf->state);\n \treturn ret;\n }\n \n@@ -3992,6 +4008,11 @@ int i40e_ndo_set_vf_port_vlan(struct net_device *netdev, int vf_id,\n \tstruct i40e_vf *vf;\n \tint ret = 0;\n \n+\tif (test_and_set_bit(__I40E_VIRTCHNL_OP_PENDING, pf->state)) {\n+\t\tdev_warn(&pf->pdev->dev, \"Unable to configure VFs, other operation is pending.\\n\");\n+\t\treturn -EAGAIN;\n+\t}\n+\n \t/* validate the request */\n \tret = i40e_validate_vf(pf, vf_id);\n \tif (ret)\n@@ -4107,6 +4128,7 @@ int i40e_ndo_set_vf_port_vlan(struct net_device *netdev, int vf_id,\n \tret = 0;\n \n error_pvid:\n+\tclear_bit(__I40E_VIRTCHNL_OP_PENDING, pf->state);\n \treturn ret;\n }\n \n@@ -4128,6 +4150,11 @@ int i40e_ndo_set_vf_bw(struct net_device *netdev, int vf_id, int min_tx_rate,\n \tstruct i40e_vf *vf;\n \tint ret = 0;\n \n+\tif (test_and_set_bit(__I40E_VIRTCHNL_OP_PENDING, pf->state)) {\n+\t\tdev_warn(&pf->pdev->dev, \"Unable to configure VFs, other operation is pending.\\n\");\n+\t\treturn -EAGAIN;\n+\t}\n+\n \t/* validate the request */\n \tret = i40e_validate_vf(pf, vf_id);\n \tif (ret)\n@@ -4154,6 +4181,7 @@ int i40e_ndo_set_vf_bw(struct net_device *netdev, int vf_id, int min_tx_rate,\n \n \tvf->tx_rate = max_tx_rate;\n error:\n+\tclear_bit(__I40E_VIRTCHNL_OP_PENDING, pf->state);\n \treturn ret;\n }\n \n@@ -4174,6 +4202,11 @@ int i40e_ndo_get_vf_config(struct net_device *netdev,\n \tstruct i40e_vf *vf;\n \tint ret = 0;\n \n+\tif (test_and_set_bit(__I40E_VIRTCHNL_OP_PENDING, pf->state)) {\n+\t\tdev_warn(&pf->pdev->dev, \"Unable to configure VFs, other operation is pending.\\n\");\n+\t\treturn -EAGAIN;\n+\t}\n+\n \t/* validate the request */\n \tret = i40e_validate_vf(pf, vf_id);\n \tif (ret)\n@@ -4209,6 +4242,7 @@ int i40e_ndo_get_vf_config(struct net_device *netdev,\n \tret = 0;\n \n error_param:\n+\tclear_bit(__I40E_VIRTCHNL_OP_PENDING, pf->state);\n \treturn ret;\n }\n \n@@ -4230,6 +4264,11 @@ int i40e_ndo_set_vf_link_state(struct net_device *netdev, int vf_id, int link)\n \tint abs_vf_id;\n \tint ret = 0;\n \n+\tif (test_and_set_bit(__I40E_VIRTCHNL_OP_PENDING, pf->state)) {\n+\t\tdev_warn(&pf->pdev->dev, \"Unable to configure VFs, other operation is pending.\\n\");\n+\t\treturn -EAGAIN;\n+\t}\n+\n \t/* validate the request */\n \tif (vf_id >= pf->num_alloc_vfs) {\n \t\tdev_err(&pf->pdev->dev, \"Invalid VF Identifier %d\\n\", vf_id);\n@@ -4273,6 +4312,7 @@ int i40e_ndo_set_vf_link_state(struct net_device *netdev, int vf_id, int link)\n \t\t\t 0, (u8 *)&pfe, sizeof(pfe), NULL);\n \n error_out:\n+\tclear_bit(__I40E_VIRTCHNL_OP_PENDING, pf->state);\n \treturn ret;\n }\n \n@@ -4294,6 +4334,11 @@ int i40e_ndo_set_vf_spoofchk(struct net_device *netdev, int vf_id, bool enable)\n \tstruct i40e_vf *vf;\n \tint ret = 0;\n \n+\tif (test_and_set_bit(__I40E_VIRTCHNL_OP_PENDING, pf->state)) {\n+\t\tdev_warn(&pf->pdev->dev, \"Unable to configure VFs, other operation is pending.\\n\");\n+\t\treturn -EAGAIN;\n+\t}\n+\n \t/* validate the request */\n \tif (vf_id >= pf->num_alloc_vfs) {\n \t\tdev_err(&pf->pdev->dev, \"Invalid VF Identifier %d\\n\", vf_id);\n@@ -4327,6 +4372,7 @@ int i40e_ndo_set_vf_spoofchk(struct net_device *netdev, int vf_id, bool enable)\n \t\tret = -EIO;\n \t}\n out:\n+\tclear_bit(__I40E_VIRTCHNL_OP_PENDING, pf->state);\n \treturn ret;\n }\n \n@@ -4345,15 +4391,22 @@ int i40e_ndo_set_vf_trust(struct net_device *netdev, int vf_id, bool setting)\n \tstruct i40e_vf *vf;\n \tint ret = 0;\n \n+\tif (test_and_set_bit(__I40E_VIRTCHNL_OP_PENDING, pf->state)) {\n+\t\tdev_warn(&pf->pdev->dev, \"Unable to configure VFs, other operation is pending.\\n\");\n+\t\treturn -EAGAIN;\n+\t}\n+\n \t/* validate the request */\n \tif (vf_id >= pf->num_alloc_vfs) {\n \t\tdev_err(&pf->pdev->dev, \"Invalid VF Identifier %d\\n\", vf_id);\n-\t\treturn -EINVAL;\n+\t\tret = -EINVAL;\n+\t\tgoto out;\n \t}\n \n \tif (pf->flags & I40E_FLAG_MFP_ENABLED) {\n \t\tdev_err(&pf->pdev->dev, \"Trusted VF not supported in MFP mode.\\n\");\n-\t\treturn -EINVAL;\n+\t\tret = -EINVAL;\n+\t\tgoto out;\n \t}\n \n \tvf = &pf->vf[vf_id];\n@@ -4376,5 +4429,6 @@ int i40e_ndo_set_vf_trust(struct net_device *netdev, int vf_id, bool setting)\n \t}\n \n out:\n+\tclear_bit(__I40E_VIRTCHNL_OP_PENDING, pf->state);\n \treturn ret;\n }\n", "prefixes": [ "next", "S97", "v2", "4/6" ] }