From patchwork Tue Nov 22 19:40:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Jurgens X-Patchwork-Id: 9442061 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7031F60235 for ; Tue, 22 Nov 2016 20:01:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5A4301FF15 for ; Tue, 22 Nov 2016 20:01:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4DEA11FF2F; Tue, 22 Nov 2016 20:01:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from emsm-gh1-uea10.nsa.gov (emsm-gh1-uea10.nsa.gov [8.44.101.8]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B3E5E1FF15 for ; Tue, 22 Nov 2016 20:01:06 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.31,682,1473120000"; d="scan'208";a="1227668" IronPort-PHdr: =?us-ascii?q?9a23=3AtfzLGhQfx/ULy9cqhZtNNs9KOdpsv+yvbD5Q0YIu?= =?us-ascii?q?jvd0So/mwa68YRWBt8tkgFKBZ4jH8fUM07OQ6PG7HzZdqs/b7zgrS99lb1c9k8?= =?us-ascii?q?IYnggtUoauKHbQC7rUVRE8B9lIT1R//nu2YgB/Ecf6YEDO8DXptWZBUhrwOhBo?= =?us-ascii?q?KevrB4Xck9q41/yo+53Ufg5E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Q+zylF2CTTlTam6xX6?= =?us-ascii?q?0m5TE7D5+mAJzARo+3g7yB2zq7EodRZmBcBVCGCW3oeJmcW/cQdCKSJddsnSYZ?= =?us-ascii?q?Wri7So8uywuuuRTgxLV7K+rY4CoYtYjs1NJt/e3ciQky9SBoD8Say2yNT397nm?= =?us-ascii?q?cMRz8xx61/pVF9ykuE0ah9mfNUD9tT5+lGUg0iL57T0/R6C8zuWgLGZtqJU1im?= =?us-ascii?q?Qs+hATEqUtI82MQOY0B6G9SsixDMxSyqD6UTl7OVGJw+6rjc0GTpJ8Zh13bG07?= =?us-ascii?q?Esjlc8TctLKW2pmLR/9xPICo7XjUqZjb2ldbkZ3CLX82eD12WOtllCUAFsSaXF?= =?us-ascii?q?QWwfZkzOoNTl+0zNUr6uBq4jMgZa1cGCLa5KZcHzglVdWPfvItLebHytm22oHx?= =?us-ascii?q?aH2quMbJb2e2UaxCjdDkkEkwQX/XmYLggzHT2urHzEDDxpD17vZFns8eZmonOh?= =?us-ascii?q?UkA01x2Kb1Fm17et5xEan+CcROkN0bIKtyYssCl7HFan0NLMF9qPuRBhcL9aYd?= =?us-ascii?q?wj/FdNzXjZuBBlPpy8M6BigUYTcxp2v0zyyxV3DZ9AndI2o3MqywpyL62Y3UhF?= =?us-ascii?q?dzOZ25D/IKfXKm7o8BCoca7W1UnU0MyK9acX9PQ4t1LjsRmtFkoj6HVnz8BZ02?= =?us-ascii?q?CC6ZXODQoSV4/xU0ks+hhhv7HaYy8954LI2n13K6W0tCHN284xDus/1hmgZ8tf?= =?us-ascii?q?ML+DFALqCc0aAMyuKOg0lFizch0EO+5T+bUvP8O7a/SGw7SnPOF6nDKplW5H+p?= =?us-ascii?q?xy0lqQ9ypgTe7Fx44FzOuF3guDTTvzlk2tvdvwmYBAeTESGWy/xDPhBIJNYK1y?= =?us-ascii?q?epoEBX2oI8Kp2tV0n4TtVGJA9F6/G1MG39ekeR+Wb1DkwwJQ018aoWK5liu8yz?= =?us-ascii?q?x7jSsporC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p4M3mXHyKYF014dlS5u?= =?us-ascii?q?bCKgEa8aui7TVq3QlbFYDwUBZyN1KsRI87o23hNRNs7DltP1yrl4g+YuBFdEWl?= =?us-ascii?q?zhncepaNcXLG6jL1zHBVyENLKcKT3M2cH3bru2SadMg+VMqx2wpTGbHlf5MTSM?= =?us-ascii?q?jTbpSQ6gPPpLjCGDIhNevoS9fQxsCWjnV93mbRK6PMVwjT0szr0+nmnKOnIEMT?= =?us-ascii?q?hgb0NNqaWd7T9fgvV6AWBB9H1lLOialCaf9ObYMJEWvuVoAilvi+1a53E6xKdP?= =?us-ascii?q?4yFfWPx5gi3SocByo1u+iOmA1iJnUAZSqjZMnI+LvkVjOaHH+ZRbXHbE+xwN7W?= =?us-ascii?q?uOBBQWu9tlCtrvu6VOxdTVkqL8NitC+crO/cQAH8jUNN6HMH05PBroHj7UEBUK?= =?us-ascii?q?TTq1OmHamUNdjOuS932Oo5g9spjjhpwOSrpBW1w0EvMVEUNlHdMYLJdwRDMknq?= =?us-ascii?q?aRjNQU6nqmsBnRWMJas4jBVv2MG/rvLC2UjbpDZxsT3bP3N4ITNpb420xjcFV6?= =?us-ascii?q?mprFG1bIV9BXviJhdhM0oFlK8HVmVG08xVnlZR23738JCfG0ngU7hRB/YeQ36T?= =?us-ascii?q?js5Fk3JkLQpCQukEg9g9Plji6NcDTpNqe/QZlWCzbot0g2Kp70XgF1bQu0nUN5?= =?us-ascii?q?KjjEQ7NRgqB6em91kg/cvoFDGflGTa1LeBUQ3+2YZ+000VRArSWq3VJI6vHbCZ?= =?us-ascii?q?tjiQQqaoWhoGha2wJ5a940K7fQK7RVwVhNnKKOvzOo1+ArzA8YOUkN7HuYeDQU?= =?us-ascii?q?t0wQKrkmOy2o8/Rx5gyZhTRMYmcMV+AwrfJ07U49IP6PzyH9075ZME+9LeifL7?= =?us-ascii?q?6fu2faj86EW08w1kQLl0hF+rh6y8EjfFSIV0o31rueCwwJNdbeKQFSd8dS+mLT?= =?us-ascii?q?cjiTvuX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?q?plBVUZBusUHaaX/YRZhmo4mfbWNscRcqBZnmaADwCkH6QHyX627yuXPGhljQ3P?= =?us-ascii?q?0x7qR2Oz90X6rShiQSvD193jiFZaVqGrBUdOWCqkIUl4sDeUMQrpstr3vL457E?= =?us-ascii?q?AwMmzqrtKCjnChOK9NH83iONOcPTQ0pEgJg5ErQdyvw48bE8KnINgN6HF+cufe?= =?us-ascii?q?62Szni9HoqdIm43e4sWP9fXMB3Wgjqqaq7KWxDBD0XU4uF4y69+6OvHJ/d2KTO?= =?us-ascii?q?yi13wNQCdnpwvBQxm1p6THoF8OPUyEzlzLmJAKP9FexnQ4zV3p5Ok9T9I16AVe?= =?us-ascii?q?F5zPa+kEpT/tJDv+2UyfbM4vVimCzztXGUr4EV1jGKg52G/9p8zJmmnN9F0vXI?= =?us-ascii?q?l/bVTnhQZwD4U6N00i9EQXzjAEEQgXZhCRFKuoClj9LYsYSUgDbgyK3L2+eqgp?= =?us-ascii?q?2E1zxa2g5OvIYOxzGaUNMe1djhaUk1hHG5IZq6keQLN6e19B6qHXogziC4noX/?= =?us-ascii?q?f4k3o/KeO6Ttpc8c8Hq3so+hy/SAa46Zdf87Ybj4iFdqxFYZjJp8186llo5D4R?= =?us-ascii?q?eSxXgRh/iRy5XfoapO/9/tjRqICo5fq2VKYxW+UX8AA5B2V/jpTqml8svcra1/?= =?us-ascii?q?xCRY3Jl4vw7BpBI3mQuIbVyxN8M/YBK5q3fLZ88HUKPzMRJ3MVPduYcfY84S5t?= =?us-ascii?q?MCnL51NYH8MMYcgVM9bKmQ9JlELmQqxT9tDcGl+CEYh/bcco73D4yDot65szTv?= =?us-ascii?q?7g6COqJZDY91xNJ+lMjDlwm9LCqukVxuDSCCsO7XmCdRd1xiKCy5+QC/f/5uiM?= =?us-ascii?q?0MvbV08aES42XYZdIyCC+Q+9Suq2iprpSAWU5dH3gJ4kc0KQXHOxlrwfsqlQCe?= =?us-ascii?q?5Aljn73j9GG4DpnfKard6s53FRtlJZC4t88BzFG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= =?us-ascii?q?MH3x9K5sJgNpbgHRfKi0gtXtpu+TfptUoHvW4UgqLCbSvB0DzvK0QBd+b5CtgH?= =?us-ascii?q?XyO44/SS5br91qERtmB4pPG8UPrwa9BJ6Ugq67gcer+0xmo+8KrbbwCvfS2dS3?= =?us-ascii?q?wYpxW5la5VSVMzvKBahrg0FljuGsjffa1pn+F9nuedQeVOh0WmTFcKPJHp2jKj?= =?us-ascii?q?KSPcLxY05G86Kc0LJ+VxWefjv5UrGDtC2lKPVk+1s0xpZ/fOrJwzwn96vb18fq?= =?us-ascii?q?Z2FHuiejqmaENZVH7FzQBOzRQwxbROGA8GZkAa0Xd5X7+P0JMdw4z9iW+xNz4y?= =?us-ascii?q?ha0MuZP6ihqVfB2kV/dZ3FN0bpwyI5VpMRIBSjMEsjnXPZqm7DDntCNMSkL9di?= =?us-ascii?q?gMqNBBz3+0ZxgX0tZnJGGmfwQdeROG4b29+xZQGT8AJLDs0Dn/KseUMjt629U+?= =?us-ascii?q?9oOpJfleWtrrUHns5jKzvTS8hCIyHQMLh2MyJKDurRoFgoYxgEs6U6W4syapaO?= =?us-ascii?q?PEMHP1maySzs1QvNy1b5d9+y26aTJiYZ7HFHwKnY0ThDvQW5vuyZgsL7WrDDcJ?= =?us-ascii?q?72ROLSMDYiVjyCQTQyEF2p+Uu/tvsFpfqYJ30QrkoSYi2MFA4ZvrpvosTIDm/P?= =?us-ascii?q?he1je4UHhPWAVC/sSC14lawyBiFQuECSQvoDExfZb3vggGpapQyjKeVA/XX/b7?= =?us-ascii?q?2X3qBVQfAZApNQcv2FRNvVYfJeKC0rljUeI+mxZMDcr7Al0lLISmsZDqbI9F2C?= =?us-ascii?q?TEKMRPyT2S7rV50Pv4cooioo5s7QnihvHqTHJbmQvCSu8o+mgyacouDeSG0tbF?= =?us-ascii?q?YugOIDHWmN2h9AJ38YC9sNokHiXraAZ1pQ1HIuke9u2RoMeANpUn10031Wh+2w?= =?us-ascii?q?GstDRl4RkmyuQecKbFdtDDM/5UWK+BH9YcQcucDPQG9T7qUDSYgaLPko7onXI6?= =?us-ascii?q?wQwPAy0TJpuiw6rjudAE1Hjg6f9arfAr58zKVY5WYk5/F2Ql2PQzTHf2jcxIqm?= =?us-ascii?q?Dt5AyCZtrH3/ycrboPptNLpbpoF+BlcGGyR2Kc7B/TpZS2H7xBOyvwqnHDSZOD?= =?us-ascii?q?8Z4jELJSoBdutuyu90rgvHdtjG6UOKq60utlGnCQCVBbqoi9R3DZTi1R+5cjZj?= =?us-ascii?q?ajK2DNVtrfILk8wdJes/bJW6K0jIMwy7CwWfoS1K/x/v5vywAdFi3nQVkqJqLs?= =?us-ascii?q?rgGYYNE52R0Slx2XdT7IIG12yKGtfWbZC/7NZ3QTkCMpSxR37xbLrTMjnyvexF?= =?us-ascii?q?2ZArUw6JZewcemJWvYInvmbsc16sv4z3+2vFLqi8Mya+I8wIK4ivgGpmjaPIN4?= =?us-ascii?q?eo7PtHWlQd+q1ppcrG/VLDsDuRZ83/KnP3xBQkMh+EbMmX/Zh7NY5qZLRvR4gz?= =?us-ascii?q?E3kSugEyL6hkT/mlryHmjFKaBe8=3D?= X-IPAS-Result: =?us-ascii?q?A2HdBAAPozRY/wHyM5BdHAEBBAEBCgEBFwEBBAEBCgEBgw0?= =?us-ascii?q?BAQEBAR9YgQGkWZZwIAOCS4VTUwEBAQEBAQEBAgECXyiCMxqBBSwNXgIEAQIXA?= =?us-ascii?q?QwTFCALAwMJAQEXCCEICAMBLRURBwcLBRgEiEwEsU49KgKLLwEkjzMKBwGFfQE?= =?us-ascii?q?EiE0DhiiBNYohhkeDD4MOhBuBbxc4h1wMhgSHT4YXhAxVXjQegyocgV9whU8PF?= =?us-ascii?q?4IXAQEB?= Received: from unknown (HELO tarius.tycho.ncsc.mil) ([144.51.242.1]) by emsm-gh1-uea10.nsa.gov with ESMTP; 22 Nov 2016 20:01:03 +0000 Received: from prometheus.infosec.tycho.ncsc.mil (prometheus [192.168.25.40]) by tarius.tycho.ncsc.mil (8.14.4/8.14.4) with ESMTP id uAMK0jrI024460; Tue, 22 Nov 2016 15:00:50 -0500 Received: from tarius.tycho.ncsc.mil (tarius.infosec.tycho.ncsc.mil [144.51.242.1]) by prometheus.infosec.tycho.ncsc.mil (8.15.2/8.15.2) with ESMTP id uAMJlqXt031490 for ; Tue, 22 Nov 2016 14:47:52 -0500 Received: from goalie.tycho.ncsc.mil (goalie [144.51.242.250]) by tarius.tycho.ncsc.mil (8.14.4/8.14.4) with ESMTP id uAMJlq9i019336 for ; Tue, 22 Nov 2016 14:47:52 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A1B7BADZnzRY/4GlL8FdHAEBBAEBCgEBgzgBAQEBAXeBAaRZlnMggkuDNgKCbQECAQEBAQECYiiEaQIEGgEMUhAYCDFXBxKIcbFIPYtQDCWPPYYFBYhNA4YogTWKIYZHgw+DDoQbgW8XOIdohgSHT4YXhAxVgRIegyocgV88NIVPgj0BAQE X-IPAS-Result: A1B7BADZnzRY/4GlL8FdHAEBBAEBCgEBgzgBAQEBAXeBAaRZlnMggkuDNgKCbQECAQEBAQECYiiEaQIEGgEMUhAYCDFXBxKIcbFIPYtQDCWPPYYFBYhNA4YogTWKIYZHgw+DDoQbgW8XOIdohgSHT4YXhAxVgRIegyocgV88NIVPgj0BAQE X-IronPort-AV: E=Sophos;i="5.31,682,1473134400"; d="scan'208";a="5839057" Received: from emsm-gh1-uea11.corp.nsa.gov (HELO emsm-gh1-uea11.nsa.gov) ([10.208.41.37]) by goalie.tycho.ncsc.mil with ESMTP; 22 Nov 2016 14:47:51 -0500 IronPort-PHdr: =?us-ascii?q?9a23=3ARUP+DxEaAKXl9W8NmDMvY51GYnF86YWxBRYc798d?= =?us-ascii?q?s5kLTJ7zrsmwAkXT6L1XgUPTWs2DsrQf2rGQ6f2rADZfqb+681k6OKRWUBEEjc?= =?us-ascii?q?hE1ycBO+WiTXPBEfjxciYhF95DXlI2t1uyMExSBdqsLwaK+i764jEdAAjwOhRo?= =?us-ascii?q?LerpBIHSk9631+ev8JHPfglEnjSwbLd8IRmsswnctsYajZZ8Jqsz1xDEvmZGd+?= =?us-ascii?q?NKyG1yOFmdhQz85sC+/J5i9yRfpfcs/NNeXKv5Yqo1U6VWACwpPG4p6sLrswLD?= =?us-ascii?q?TRaU6XsHTmoWiBtIDBPb4xz8Q5z8rzH1tut52CmdIM32UbU5Uims4qt3VBPljj?= =?us-ascii?q?oMOiUn+2/LlMN/kKNboAqgpxNhxY7UfJqVP+d6cq/EYN8WWXZNUsNXWidcAI2z?= =?us-ascii?q?cpEPAvIBM+hGsofzqVgAoxy8CgmiH+7j1iNEi2Xq0aAgz+gtDQfL1xEgEdIUt3?= =?us-ascii?q?TUqc34OqkIXuCz0aLGySjDb+lZ2Tjj7ojIaQ0qrPaRUr1qd8rRyFcgFwfHjliL?= =?us-ascii?q?rIzqITeV1uAXvGid6OphWvijhHIgqwF0uzWiwNonhIfOhoIQ0F/E9CN5zZ4yJd?= =?us-ascii?q?2gVkF7Z9+kH4BKuyGdLYt2TcUvSHxrtiYi0rAKpJq2cSYQxJkoxRPTceGLfomI?= =?us-ascii?q?7x75SeqdPzN1iXR4c7ylnRmy61KvyujkW8m0zllKqi1Fn8HJtn8T0xzT7tKISv?= =?us-ascii?q?16/kauwzqAywfT5vtFIUAwjabbKpghzaAslpcLrEjOGiH7lF/5gaKUbEko5+ml?= =?us-ascii?q?5uT9brn7uJORM5d4igTkPaQvnsy/D/44Mg8LX2WD5Ouzzrvj/UznT7VOjP07ia?= =?us-ascii?q?zZv47eJcQfvKG5BQhV04k55xmjCDem1cwUnWMbI1JdZBKHk4/pNknVIP/mCfe/?= =?us-ascii?q?glKskCpkxv3dIr3gAonCLnjEkLv7e7Z98FRTxBA8zdBY+ZIHQo0GdfnzQE7qq/?= =?us-ascii?q?TDCQIidhezx6DgEto5npsXRGanGqaENObXtliS66QkJOzILJQZox7hOvMl4Ljo?= =?us-ascii?q?lnZ/llgDOeGkxZINaWuQBv18Il6BZXPnj5EGC2hO9gY6QeDkj0eOeSRea3a7Q+?= =?us-ascii?q?Q34TR/QJmrBIGFRo2jnK2p3SGnE5kQbWdDThiMGHOubYKfVvEXdCWZIedulzUF?= =?us-ascii?q?Uf6qTIpy+wupsVrWwrwvDPfO9SAertq32NFz5uDXlzk3+DhwBsKawyeGSGQizT?= =?us-ascii?q?BAfCM/wK0q+R818VyEy6UtxqUATdE=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0F8BADAoDRY/4GlL8FdHAEBBAEBCgEBF?= =?us-ascii?q?wEBBAEBCgEBgw0BAQEBAXeBAaRZlnMggkuDNgKCbgEBAQEBAQEBAgECXyiCMxo?= =?us-ascii?q?BgQQsDV4CBBoBDFIQGAgxVwcSiHGxST2LUAwljz2GBQWITQOGKIE1iiGGR4MPg?= =?us-ascii?q?w6EG4FvFziHaIYEh0+GF4QMVYESHoMqHIFfPDSFT4I9AQEB?= X-IPAS-Result: =?us-ascii?q?A0F8BADAoDRY/4GlL8FdHAEBBAEBCgEBFwEBBAEBCgEBgw0?= =?us-ascii?q?BAQEBAXeBAaRZlnMggkuDNgKCbgEBAQEBAQEBAgECXyiCMxoBgQQsDV4CBBoBD?= =?us-ascii?q?FIQGAgxVwcSiHGxST2LUAwljz2GBQWITQOGKIE1iiGGR4MPgw6EG4FvFziHaIY?= =?us-ascii?q?Eh0+GF4QMVYESHoMqHIFfPDSFT4I9AQEB?= X-IronPort-AV: E=Sophos;i="5.31,682,1473120000"; d="scan'208";a="996047" Received: from mail-il-dmz.mellanox.com (HELO mellanox.co.il) ([193.47.165.129]) by emsm-gh1-uea11.nsa.gov with ESMTP; 22 Nov 2016 19:47:42 +0000 Received: from Internal Mail-Server by MTLPINE1 (envelope-from danielj@mellanox.com) with ESMTPS (AES256-SHA encrypted); 22 Nov 2016 21:40:58 +0200 Received: from x-vnc01.mtx.labs.mlnx. (x-vnc01.mtx.labs.mlnx [10.12.150.16]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id uAMJenMW005134; Tue, 22 Nov 2016 21:40:55 +0200 From: Dan Jurgens To: chrisw@sous-sol.org, paul@paul-moore.com, sds@tycho.nsa.gov, eparis@parisplace.org, dledford@redhat.com, sean.hefty@intel.com, hal.rosenstock@gmail.com Subject: [PATCH v5 2/9] IB/core: Enforce PKey security on QPs Date: Tue, 22 Nov 2016 21:40:31 +0200 Message-Id: <1479843638-67136-3-git-send-email-danielj@mellanox.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1479843638-67136-1-git-send-email-danielj@mellanox.com> References: <1479843638-67136-1-git-send-email-danielj@mellanox.com> X-Mailman-Approved-At: Tue, 22 Nov 2016 15:00:44 -0500 X-BeenThere: selinux@tycho.nsa.gov X-Mailman-Version: 2.1.20 Precedence: list List-Id: "Security-Enhanced Linux \(SELinux\) mailing list" List-Post: List-Help: Cc: linux-rdma@vger.kernel.org, linux-security-module@vger.kernel.org, selinux@tycho.nsa.gov MIME-Version: 1.0 Errors-To: selinux-bounces@tycho.nsa.gov Sender: "Selinux" X-Virus-Scanned: ClamAV using ClamSMTP From: Daniel Jurgens Add new LSM hooks to allocate and free security contexts and check for permission to access a PKey. Allocate and free a security context when creating and destroying a QP. This context is used for controlling access to PKeys. When a request is made to modify a QP that changes the port, PKey index, or alternate path, check that the QP has permission for the PKey in the PKey table index on the subnet prefix of the port. If the QP is shared make sure all handles to the QP also have access. Store which port and PKey index a QP is using. After the reset to init transition the user can modify the port, PKey index and alternate path independently. So port and PKey settings changes can be a merge of the previous settings and the new ones. In order to maintain access control if there are PKey table or subnet prefix change keep a list of all QPs are using each PKey index on each port. If a change occurs all QPs using that device and port must have access enforced for the new cache settings. These changes add a transaction to the QP modify process. Association with the old port and PKey index must be maintained if the modify fails, and must be removed if it succeeds. Association with the new port and PKey index must be established prior to the modify and removed if the modify fails. 1. When a QP is modified to a particular Port, PKey index or alternate path insert that QP into the appropriate lists. 2. Check permission to access the new settings. 3. If step 2 grants access attempt to modify the QP. 4a. If steps 2 and 3 succeed remove any prior associations. 4b. If ether fails remove the new setting associations. If a PKey table or subnet prefix changes walk the list of QPs and check that they have permission. If not send the QP to the error state and raise a fatal error event. If it's a shared QP make sure all the QPs that share the real_qp have permission as well. If the QP that owns a security structure is denied access the security structure is marked as such and the QP is added to an error_list. Once the moving the QP to error is complete the security structure mark is cleared. Maintaining the lists correctly turns QP destroy into a transaction. The hardware driver for the device frees the ib_qp structure, so while the destroy is in progress the ib_qp pointer in the ib_qp_security struct is undefined. When the destroy process begins the ib_qp_security structure is marked as destroying. This prevents any action from being taken on the QP pointer. After the QP is destroyed successfully it could still listed on an error_list wait for it to be processed by that flow before cleaning up the structure. If the destroy fails the QPs port and PKey settings are reinserted into the appropriate lists, the destroying flag is cleared, and access control is enforced, in case there were any cache changes during the destroy flow. To keep the security changes isolated a new file is used to hold security related functionality. Signed-off-by: Daniel Jurgens --- v2: - Squashed LSM hook additions. Paul Moore - Changed security blobs to void*. Paul Moore v3: - Change parameter order of pkey_access hook. Paul Moore --- drivers/infiniband/core/Makefile | 3 +- drivers/infiniband/core/cache.c | 21 +- drivers/infiniband/core/core_priv.h | 77 +++++ drivers/infiniband/core/device.c | 33 ++ drivers/infiniband/core/security.c | 617 +++++++++++++++++++++++++++++++++++ drivers/infiniband/core/uverbs_cmd.c | 20 +- drivers/infiniband/core/verbs.c | 27 +- include/linux/lsm_hooks.h | 27 ++ include/linux/security.h | 21 ++ include/rdma/ib_verbs.h | 48 +++ security/Kconfig | 9 + security/security.c | 31 ++ 12 files changed, 925 insertions(+), 9 deletions(-) create mode 100644 drivers/infiniband/core/security.c diff --git a/drivers/infiniband/core/Makefile b/drivers/infiniband/core/Makefile index edaae9f..da4e2c1 100644 --- a/drivers/infiniband/core/Makefile +++ b/drivers/infiniband/core/Makefile @@ -10,7 +10,8 @@ obj-$(CONFIG_INFINIBAND_USER_ACCESS) += ib_uverbs.o ib_ucm.o \ ib_core-y := packer.o ud_header.o verbs.o cq.o rw.o sysfs.o \ device.o fmr_pool.o cache.o netlink.o \ roce_gid_mgmt.o mr_pool.o addr.o sa_query.o \ - multicast.o mad.o smi.o agent.o mad_rmpp.o + multicast.o mad.o smi.o agent.o mad_rmpp.o \ + security.o ib_core-$(CONFIG_INFINIBAND_USER_MEM) += umem.o ib_core-$(CONFIG_INFINIBAND_ON_DEMAND_PAGING) += umem_odp.o umem_rbtree.o diff --git a/drivers/infiniband/core/cache.c b/drivers/infiniband/core/cache.c index affc8ef..48eaeca 100644 --- a/drivers/infiniband/core/cache.c +++ b/drivers/infiniband/core/cache.c @@ -53,6 +53,7 @@ struct ib_update_work { struct work_struct work; struct ib_device *device; u8 port_num; + bool enforce_security; }; union ib_gid zgid; @@ -1046,7 +1047,8 @@ int ib_get_cached_lmc(struct ib_device *device, EXPORT_SYMBOL(ib_get_cached_lmc); static void ib_cache_update(struct ib_device *device, - u8 port) + u8 port, + bool enforce_security) { struct ib_port_attr *tprops = NULL; struct ib_pkey_cache *pkey_cache = NULL, *old_pkey_cache; @@ -1134,6 +1136,11 @@ static void ib_cache_update(struct ib_device *device, tprops->subnet_prefix; write_unlock_irq(&device->cache.lock); + if (enforce_security) + ib_security_cache_change(device, + port, + tprops->subnet_prefix); + kfree(gid_cache); kfree(old_pkey_cache); kfree(tprops); @@ -1150,7 +1157,9 @@ static void ib_cache_task(struct work_struct *_work) struct ib_update_work *work = container_of(_work, struct ib_update_work, work); - ib_cache_update(work->device, work->port_num); + ib_cache_update(work->device, + work->port_num, + work->enforce_security); kfree(work); } @@ -1171,6 +1180,12 @@ static void ib_cache_event(struct ib_event_handler *handler, INIT_WORK(&work->work, ib_cache_task); work->device = event->device; work->port_num = event->element.port_num; + if (event->event == IB_EVENT_PKEY_CHANGE || + event->event == IB_EVENT_GID_CHANGE) + work->enforce_security = true; + else + work->enforce_security = false; + queue_work(ib_wq, &work->work); } } @@ -1211,7 +1226,7 @@ int ib_cache_setup_one(struct ib_device *device) return err; for (p = 0; p <= rdma_end_port(device) - rdma_start_port(device); ++p) - ib_cache_update(device, p + rdma_start_port(device)); + ib_cache_update(device, p + rdma_start_port(device), true); INIT_IB_EVENT_HANDLER(&device->cache.event_handler, device, ib_cache_event); diff --git a/drivers/infiniband/core/core_priv.h b/drivers/infiniband/core/core_priv.h index ce826e4..68e3de0 100644 --- a/drivers/infiniband/core/core_priv.h +++ b/drivers/infiniband/core/core_priv.h @@ -38,6 +38,14 @@ #include +struct pkey_index_qp_list { + struct list_head pkey_index_list; + u16 pkey_index; + /* Lock to hold while iterating the qp_list. */ + spinlock_t qp_list_lock; + struct list_head qp_list; +}; + #if IS_ENABLED(CONFIG_INFINIBAND_ADDR_TRANS_CONFIGFS) int cma_configfs_init(void); void cma_configfs_exit(void); @@ -156,4 +164,73 @@ int ib_nl_handle_ip_res_resp(struct sk_buff *skb, int ib_get_cached_subnet_prefix(struct ib_device *device, u8 port_num, u64 *sn_pfx); + +#ifdef CONFIG_SECURITY_INFINIBAND +void ib_security_destroy_port_pkey_list(struct ib_device *device); + +void ib_security_cache_change(struct ib_device *device, + u8 port_num, + u64 subnet_prefix); + +int ib_security_modify_qp(struct ib_qp *qp, + struct ib_qp_attr *qp_attr, + int qp_attr_mask, + struct ib_udata *udata); + +int ib_create_qp_security(struct ib_qp *qp, struct ib_device *dev); +void ib_destroy_qp_security_begin(struct ib_qp_security *sec); +void ib_destroy_qp_security_abort(struct ib_qp_security *sec); +void ib_destroy_qp_security_end(struct ib_qp_security *sec); +int ib_open_shared_qp_security(struct ib_qp *qp, struct ib_device *dev); +void ib_close_shared_qp_security(struct ib_qp_security *sec); +#else +static inline void ib_security_destroy_port_pkey_list(struct ib_device *device) +{ +} + +static inline void ib_security_cache_change(struct ib_device *device, + u8 port_num, + u64 subnet_prefix) +{ +} + +static inline int ib_security_modify_qp(struct ib_qp *qp, + struct ib_qp_attr *qp_attr, + int qp_attr_mask, + struct ib_udata *udata) +{ + return qp->device->modify_qp(qp->real_qp, + qp_attr, + qp_attr_mask, + udata); +} + +static inline int ib_create_qp_security(struct ib_qp *qp, + struct ib_device *dev) +{ + return 0; +} + +static inline void ib_destroy_qp_security_begin(struct ib_qp_security *sec) +{ +} + +static inline void ib_destroy_qp_security_abort(struct ib_qp_security *sec) +{ +} + +static inline void ib_destroy_qp_security_end(struct ib_qp_security *sec) +{ +} + +static inline int ib_open_shared_qp_security(struct ib_qp *qp, + struct ib_device *dev) +{ + return 0; +} + +static inline void ib_close_shared_qp_security(struct ib_qp_security *sec) +{ +} +#endif #endif /* _CORE_PRIV_H */ diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c index 760ef60..5b42e83 100644 --- a/drivers/infiniband/core/device.c +++ b/drivers/infiniband/core/device.c @@ -320,6 +320,30 @@ void ib_get_device_fw_str(struct ib_device *dev, char *str, size_t str_len) } EXPORT_SYMBOL(ib_get_device_fw_str); +static int setup_port_pkey_list(struct ib_device *device) +{ + int i; + + /** + * device->port_pkey_list is indexed directly by the port number, + * Therefore it is declared as a 1 based array with potential empty + * slots at the beginning. + */ + device->port_pkey_list = kzalloc(sizeof(*device->port_pkey_list) + * (rdma_end_port(device) + 1), + GFP_KERNEL); + + if (!device->port_pkey_list) + return -ENOMEM; + + for (i = 0; i < (rdma_end_port(device) + 1); i++) { + spin_lock_init(&device->port_pkey_list[i].list_lock); + INIT_LIST_HEAD(&device->port_pkey_list[i].pkey_list); + } + + return 0; +} + /** * ib_register_device - Register an IB device with IB core * @device:Device to register @@ -357,6 +381,12 @@ int ib_register_device(struct ib_device *device, goto out; } + ret = setup_port_pkey_list(device); + if (ret) { + dev_warn(device->dma_device, "Couldn't create per port_pkey_list\n"); + goto out; + } + ret = ib_cache_setup_one(device); if (ret) { pr_warn("Couldn't set up InfiniBand P_Key/GID cache\n"); @@ -427,6 +457,9 @@ void ib_unregister_device(struct ib_device *device) ib_device_unregister_sysfs(device); ib_cache_cleanup_one(device); + ib_security_destroy_port_pkey_list(device); + kfree(device->port_pkey_list); + down_write(&lists_rwsem); spin_lock_irqsave(&device->client_data_lock, flags); list_for_each_entry_safe(context, tmp, &device->client_data_list, list) diff --git a/drivers/infiniband/core/security.c b/drivers/infiniband/core/security.c new file mode 100644 index 0000000..45800dd --- /dev/null +++ b/drivers/infiniband/core/security.c @@ -0,0 +1,617 @@ +/* + * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifdef CONFIG_SECURITY_INFINIBAND + +#include +#include +#include + +#include +#include +#include "core_priv.h" + +static struct pkey_index_qp_list *get_pkey_idx_qp_list(struct ib_port_pkey *pp) +{ + struct pkey_index_qp_list *pkey = NULL; + struct pkey_index_qp_list *tmp_pkey; + struct ib_device *dev = pp->sec->dev; + + spin_lock(&dev->port_pkey_list[pp->port_num].list_lock); + list_for_each_entry(tmp_pkey, + &dev->port_pkey_list[pp->port_num].pkey_list, + pkey_index_list) { + if (tmp_pkey->pkey_index == pp->pkey_index) { + pkey = tmp_pkey; + break; + } + } + spin_unlock(&dev->port_pkey_list[pp->port_num].list_lock); + return pkey; +} + +static int get_pkey_and_subnet_prefix(struct ib_port_pkey *pp, + u16 *pkey, + u64 *subnet_prefix) +{ + struct ib_device *dev = pp->sec->dev; + int ret; + + ret = ib_get_cached_pkey(dev, pp->port_num, pp->pkey_index, pkey); + if (ret) + return ret; + + ret = ib_get_cached_subnet_prefix(dev, pp->port_num, subnet_prefix); + + return ret; +} + +static int enforce_qp_pkey_security(u16 pkey, + u64 subnet_prefix, + struct ib_qp_security *qp_sec) +{ + struct ib_qp_security *shared_qp_sec; + int ret; + + ret = security_ib_pkey_access(qp_sec->security, subnet_prefix, pkey); + if (ret) + return ret; + + if (qp_sec->qp == qp_sec->qp->real_qp) { + list_for_each_entry(shared_qp_sec, + &qp_sec->shared_qp_list, + shared_qp_list) { + ret = security_ib_pkey_access(shared_qp_sec->security, + subnet_prefix, + pkey); + if (ret) + return ret; + } + } + return 0; +} + +/* The caller of this function must hold the QP security + * mutex of the QP of the security structure in *pps. + * + * It takes separate ports_pkeys and security structure + * because in some cases the pps will be for a new settings + * or the pps will be for the real QP and security structure + * will be for a shared QP. + */ +static int check_qp_port_pkey_settings(struct ib_ports_pkeys *pps, + struct ib_qp_security *sec) +{ + u64 subnet_prefix; + u16 pkey; + int ret = 0; + + if (!pps) + return 0; + + if (pps->main.state != IB_PORT_PKEY_NOT_VALID) { + get_pkey_and_subnet_prefix(&pps->main, + &pkey, + &subnet_prefix); + + ret = enforce_qp_pkey_security(pkey, + subnet_prefix, + sec); + } + if (ret) + goto out; + + if (pps->alt.state != IB_PORT_PKEY_NOT_VALID) { + get_pkey_and_subnet_prefix(&pps->alt, + &pkey, + &subnet_prefix); + + ret = enforce_qp_pkey_security(pkey, + subnet_prefix, + sec); + } + + if (ret) + goto out; + +out: + return ret; +} + +/* The caller of this function must hold the QP security + * mutex. + */ +static void qp_to_error(struct ib_qp_security *sec) +{ + struct ib_qp_security *shared_qp_sec; + struct ib_qp_attr attr = { + .qp_state = IB_QPS_ERR + }; + struct ib_event event = { + .event = IB_EVENT_QP_FATAL + }; + + /* If the QP is in the process of being destroyed + * the qp pointer in the security structure is + * undefined. It cannot be modified now. + */ + if (sec->destroying) + return; + + ib_modify_qp(sec->qp, + &attr, + IB_QP_STATE); + + if (sec->qp->event_handler && sec->qp->qp_context) { + event.element.qp = sec->qp; + sec->qp->event_handler(&event, + sec->qp->qp_context); + } + + list_for_each_entry(shared_qp_sec, + &sec->shared_qp_list, + shared_qp_list) { + struct ib_qp *qp = shared_qp_sec->qp; + + if (qp->event_handler && qp->qp_context) { + event.element.qp = qp; + event.device = qp->device; + qp->event_handler(&event, + qp->qp_context); + } + } +} + +static inline void check_pkey_qps(struct pkey_index_qp_list *pkey, + struct ib_device *device, + u8 port_num, + u64 subnet_prefix) +{ + struct ib_port_pkey *pp, *tmp_pp; + bool comp; + LIST_HEAD(to_error_list); + u16 pkey_val; + + if (!ib_get_cached_pkey(device, + port_num, + pkey->pkey_index, + &pkey_val)) { + spin_lock(&pkey->qp_list_lock); + list_for_each_entry(pp, &pkey->qp_list, qp_list) { + if (atomic_read(&pp->sec->error_list_count)) + continue; + + if (enforce_qp_pkey_security(pkey_val, + subnet_prefix, + pp->sec)) { + atomic_inc(&pp->sec->error_list_count); + list_add(&pp->to_error_list, + &to_error_list); + } + } + spin_unlock(&pkey->qp_list_lock); + } + + list_for_each_entry_safe(pp, + tmp_pp, + &to_error_list, + to_error_list) { + mutex_lock(&pp->sec->mutex); + qp_to_error(pp->sec); + list_del(&pp->to_error_list); + atomic_dec(&pp->sec->error_list_count); + comp = pp->sec->destroying; + mutex_unlock(&pp->sec->mutex); + + if (comp) + complete(&pp->sec->error_complete); + } +} + +/* The caller of this function must hold the QP security + * mutex. + */ +static int port_pkey_list_insert(struct ib_port_pkey *pp) +{ + struct pkey_index_qp_list *tmp_pkey; + struct pkey_index_qp_list *pkey; + struct ib_device *dev; + u8 port_num = pp->port_num; + int ret = 0; + + if (pp->state != IB_PORT_PKEY_VALID) + return 0; + + dev = pp->sec->dev; + + pkey = get_pkey_idx_qp_list(pp); + + if (!pkey) { + bool found = false; + + pkey = kzalloc(sizeof(*pkey), GFP_KERNEL); + if (!pkey) + return -ENOMEM; + + spin_lock(&dev->port_pkey_list[port_num].list_lock); + /* Check for the PKey again. A racing process may + * have created it. + */ + list_for_each_entry(tmp_pkey, + &dev->port_pkey_list[port_num].pkey_list, + pkey_index_list) { + if (tmp_pkey->pkey_index == pp->pkey_index) { + kfree(pkey); + pkey = tmp_pkey; + found = true; + break; + } + } + + if (!found) { + pkey->pkey_index = pp->pkey_index; + spin_lock_init(&pkey->qp_list_lock); + INIT_LIST_HEAD(&pkey->qp_list); + list_add(&pkey->pkey_index_list, + &dev->port_pkey_list[port_num].pkey_list); + } + spin_unlock(&dev->port_pkey_list[port_num].list_lock); + } + + spin_lock(&pkey->qp_list_lock); + list_add(&pp->qp_list, &pkey->qp_list); + spin_unlock(&pkey->qp_list_lock); + + pp->state = IB_PORT_PKEY_LISTED; + + return ret; +} + +/* The caller of this function must hold the QP security + * mutex. + */ +static void port_pkey_list_remove(struct ib_port_pkey *pp) +{ + struct pkey_index_qp_list *pkey; + + if (pp->state != IB_PORT_PKEY_LISTED) + return; + + pkey = get_pkey_idx_qp_list(pp); + + spin_lock(&pkey->qp_list_lock); + list_del(&pp->qp_list); + spin_unlock(&pkey->qp_list_lock); + + /* The setting may still be valid, i.e. after + * a destroy has failed for example. + */ + pp->state = IB_PORT_PKEY_VALID; +} + +static void destroy_qp_security(struct ib_qp_security *sec) +{ + security_ib_free_security(sec->security); + kfree(sec->ports_pkeys); + kfree(sec); +} + +/* The caller of this function must hold the QP security + * mutex. + */ +static struct ib_ports_pkeys *get_new_pps(const struct ib_qp *qp, + const struct ib_qp_attr *qp_attr, + int qp_attr_mask) +{ + struct ib_ports_pkeys *new_pps; + struct ib_ports_pkeys *qp_pps = qp->qp_sec->ports_pkeys; + + new_pps = kzalloc(sizeof(*new_pps), GFP_KERNEL); + if (!new_pps) + return NULL; + + if (qp_attr_mask & (IB_QP_PKEY_INDEX | IB_QP_PORT)) { + if (!qp_pps) { + new_pps->main.port_num = qp_attr->port_num; + new_pps->main.pkey_index = qp_attr->pkey_index; + } else { + new_pps->main.port_num = (qp_attr_mask & IB_QP_PORT) ? + qp_attr->port_num : + qp_pps->main.port_num; + + new_pps->main.pkey_index = + (qp_attr_mask & IB_QP_PKEY_INDEX) ? + qp_attr->pkey_index : + qp_pps->main.pkey_index; + } + new_pps->main.state = IB_PORT_PKEY_VALID; + } else if (qp_pps) { + new_pps->main.port_num = qp_pps->main.port_num; + new_pps->main.pkey_index = qp_pps->main.pkey_index; + if (qp_pps->main.state != IB_PORT_PKEY_NOT_VALID) + new_pps->main.state = IB_PORT_PKEY_VALID; + } + + if (qp_attr_mask & IB_QP_ALT_PATH) { + new_pps->alt.port_num = qp_attr->alt_port_num; + new_pps->alt.pkey_index = qp_attr->alt_pkey_index; + new_pps->alt.state = IB_PORT_PKEY_VALID; + } else if (qp_pps) { + new_pps->alt.port_num = qp_pps->alt.port_num; + new_pps->alt.pkey_index = qp_pps->alt.pkey_index; + if (qp_pps->alt.state != IB_PORT_PKEY_NOT_VALID) + new_pps->alt.state = IB_PORT_PKEY_VALID; + } + + new_pps->main.sec = qp->qp_sec; + new_pps->alt.sec = qp->qp_sec; + return new_pps; +} + +int ib_open_shared_qp_security(struct ib_qp *qp, struct ib_device *dev) +{ + struct ib_qp *real_qp = qp->real_qp; + int ret; + + ret = ib_create_qp_security(qp, dev); + + if (ret) + goto out; + + mutex_lock(&real_qp->qp_sec->mutex); + ret = check_qp_port_pkey_settings(real_qp->qp_sec->ports_pkeys, + qp->qp_sec); + + if (ret) + goto ret; + + if (qp != real_qp) + list_add(&qp->qp_sec->shared_qp_list, + &real_qp->qp_sec->shared_qp_list); +ret: + mutex_unlock(&real_qp->qp_sec->mutex); + if (ret) + destroy_qp_security(qp->qp_sec); + +out: + return ret; +} + +void ib_close_shared_qp_security(struct ib_qp_security *sec) +{ + struct ib_qp *real_qp = sec->qp->real_qp; + + mutex_lock(&real_qp->qp_sec->mutex); + list_del(&sec->shared_qp_list); + mutex_unlock(&real_qp->qp_sec->mutex); + + destroy_qp_security(sec); +} + +int ib_create_qp_security(struct ib_qp *qp, struct ib_device *dev) +{ + int ret; + + qp->qp_sec = kzalloc(sizeof(*qp->qp_sec), GFP_KERNEL); + if (!qp->qp_sec) + return -ENOMEM; + + qp->qp_sec->qp = qp; + qp->qp_sec->dev = dev; + mutex_init(&qp->qp_sec->mutex); + INIT_LIST_HEAD(&qp->qp_sec->shared_qp_list); + atomic_set(&qp->qp_sec->error_list_count, 0); + init_completion(&qp->qp_sec->error_complete); + ret = security_ib_alloc_security(&qp->qp_sec->security); + if (ret) + kfree(qp->qp_sec); + + return ret; +} +EXPORT_SYMBOL(ib_create_qp_security); + +void ib_destroy_qp_security_begin(struct ib_qp_security *sec) +{ + mutex_lock(&sec->mutex); + + /* Remove the QP from the lists so it won't get added to + * a to_error_list during the destroy process. + */ + if (sec->ports_pkeys) { + port_pkey_list_remove(&sec->ports_pkeys->main); + port_pkey_list_remove(&sec->ports_pkeys->alt); + } + + /* If the QP is already in one or more of those lists + * the destroying flag will ensure the to error flow + * doesn't operate on an undefined QP. + */ + sec->destroying = true; + + /* Record the error list count to know how many completions + * to wait for. + */ + sec->error_comps_pending = atomic_read(&sec->error_list_count); + + mutex_unlock(&sec->mutex); +} + +void ib_destroy_qp_security_abort(struct ib_qp_security *sec) +{ + int ret; + int i; + + /* If a concurrent cache update is in progress this + * QP security could be marked for an error state + * transition. Wait for this to complete. + */ + for (i = 0; i < sec->error_comps_pending; i++) + wait_for_completion(&sec->error_complete); + + mutex_lock(&sec->mutex); + sec->destroying = false; + + /* Restore the position in the lists and verify + * access is still allowed in case a cache update + * occurred while attempting to destroy. + * + * Because these setting were listed already + * and removed during ib_destroy_qp_security_begin + * we know the pkey_index_qp_list for the PKey + * already exists so port_pkey_list_insert won't fail. + */ + if (sec->ports_pkeys) { + port_pkey_list_insert(&sec->ports_pkeys->main); + port_pkey_list_insert(&sec->ports_pkeys->alt); + } + + ret = check_qp_port_pkey_settings(sec->ports_pkeys, sec); + if (ret) + qp_to_error(sec); + + mutex_unlock(&sec->mutex); +} + +void ib_destroy_qp_security_end(struct ib_qp_security *sec) +{ + int i; + + /* If a concurrent cache update is occurring we must + * wait until this QP security structure is processed + * in the QP to error flow before destroying it because + * the to_error_list is in use. + */ + for (i = 0; i < sec->error_comps_pending; i++) + wait_for_completion(&sec->error_complete); + + destroy_qp_security(sec); +} + +void ib_security_cache_change(struct ib_device *device, + u8 port_num, + u64 subnet_prefix) +{ + struct pkey_index_qp_list *pkey; + + list_for_each_entry(pkey, + &device->port_pkey_list[port_num].pkey_list, + pkey_index_list) { + check_pkey_qps(pkey, + device, + port_num, + subnet_prefix); + } +} + +void ib_security_destroy_port_pkey_list(struct ib_device *device) +{ + struct pkey_index_qp_list *pkey, *tmp_pkey; + int i; + + for (i = rdma_start_port(device); i <= rdma_end_port(device); i++) { + spin_lock(&device->port_pkey_list[i].list_lock); + list_for_each_entry_safe(pkey, + tmp_pkey, + &device->port_pkey_list[i].pkey_list, + pkey_index_list) { + list_del(&pkey->pkey_index_list); + kfree(pkey); + } + spin_unlock(&device->port_pkey_list[i].list_lock); + } +} + +int ib_security_modify_qp(struct ib_qp *qp, + struct ib_qp_attr *qp_attr, + int qp_attr_mask, + struct ib_udata *udata) +{ + int ret = 0; + struct ib_ports_pkeys *tmp_pps; + struct ib_ports_pkeys *new_pps; + bool special_qp = (qp->qp_type == IB_QPT_SMI || + qp->qp_type == IB_QPT_GSI); + bool pps_change = ((qp_attr_mask & (IB_QP_PKEY_INDEX | IB_QP_PORT)) || + (qp_attr_mask & IB_QP_ALT_PATH)); + + if (pps_change && !special_qp) { + mutex_lock(&qp->qp_sec->mutex); + new_pps = get_new_pps(qp, + qp_attr, + qp_attr_mask); + + /* Add this QP to the lists for the new port + * and pkey settings before checking for permission + * in case there is a concurrent cache update + * occurring. Walking the list for a cache change + * doesn't acquire the security mutex unless it's + * sending the QP to error. + */ + ret = port_pkey_list_insert(&new_pps->main); + + if (!ret) + ret = port_pkey_list_insert(&new_pps->alt); + + if (!ret) + ret = check_qp_port_pkey_settings(new_pps, + qp->qp_sec); + } + + if (!ret) + ret = qp->device->modify_qp(qp->real_qp, + qp_attr, + qp_attr_mask, + udata); + + if (pps_change && !special_qp) { + /* Clean up the lists and free the appropriate + * ports_pkeys structure. + */ + if (ret) { + tmp_pps = new_pps; + } else { + tmp_pps = qp->qp_sec->ports_pkeys; + qp->qp_sec->ports_pkeys = new_pps; + } + + if (tmp_pps) { + port_pkey_list_remove(&tmp_pps->main); + port_pkey_list_remove(&tmp_pps->alt); + } + kfree(tmp_pps); + mutex_unlock(&qp->qp_sec->mutex); + } + return ret; +} +EXPORT_SYMBOL(ib_security_modify_qp); + +#endif /* CONFIG_SECURITY_INFINIBAND */ diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index cb3f515a..ceb9154 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c @@ -37,7 +37,7 @@ #include #include #include - +#include #include #include "uverbs.h" @@ -1915,6 +1915,10 @@ static int create_qp(struct ib_uverbs_file *file, } if (cmd->qp_type != IB_QPT_XRC_TGT) { + ret = ib_create_qp_security(qp, device); + if (ret) + goto err_destroy; + qp->real_qp = qp; qp->device = device; qp->pd = pd; @@ -2405,10 +2409,18 @@ ssize_t ib_uverbs_modify_qp(struct ib_uverbs_file *file, ret = ib_resolve_eth_dmac(qp, attr, &cmd.attr_mask); if (ret) goto release_qp; - ret = qp->device->modify_qp(qp, attr, - modify_qp_mask(qp->qp_type, cmd.attr_mask), &udata); + + ret = ib_security_modify_qp(qp, + attr, + modify_qp_mask(qp->qp_type, + cmd.attr_mask), + &udata); } else { - ret = ib_modify_qp(qp, attr, modify_qp_mask(qp->qp_type, cmd.attr_mask)); + ret = ib_security_modify_qp(qp, + attr, + modify_qp_mask(qp->qp_type, + cmd.attr_mask), + NULL); } if (ret) diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c index 8368764..9845e37 100644 --- a/drivers/infiniband/core/verbs.c +++ b/drivers/infiniband/core/verbs.c @@ -44,6 +44,7 @@ #include #include #include +#include #include #include @@ -708,12 +709,20 @@ static struct ib_qp *__ib_open_qp(struct ib_qp *real_qp, { struct ib_qp *qp; unsigned long flags; + int err; qp = kzalloc(sizeof *qp, GFP_KERNEL); if (!qp) return ERR_PTR(-ENOMEM); qp->real_qp = real_qp; + err = ib_open_shared_qp_security(qp, real_qp->device); + if (err) { + kfree(qp); + return ERR_PTR(err); + } + + qp->real_qp = real_qp; atomic_inc(&real_qp->usecnt); qp->device = real_qp->device; qp->event_handler = event_handler; @@ -799,6 +808,12 @@ struct ib_qp *ib_create_qp(struct ib_pd *pd, if (IS_ERR(qp)) return qp; + ret = ib_create_qp_security(qp, device); + if (ret) { + ib_destroy_qp(qp); + return ERR_PTR(ret); + } + qp->device = device; qp->real_qp = qp; qp->uobject = NULL; @@ -1257,7 +1272,7 @@ int ib_modify_qp(struct ib_qp *qp, if (ret) return ret; - return qp->device->modify_qp(qp->real_qp, qp_attr, qp_attr_mask, NULL); + return ib_security_modify_qp(qp->real_qp, qp_attr, qp_attr_mask, NULL); } EXPORT_SYMBOL(ib_modify_qp); @@ -1286,6 +1301,7 @@ int ib_close_qp(struct ib_qp *qp) spin_unlock_irqrestore(&real_qp->device->event_handler_lock, flags); atomic_dec(&real_qp->usecnt); + ib_close_shared_qp_security(qp->qp_sec); kfree(qp); return 0; @@ -1326,6 +1342,7 @@ int ib_destroy_qp(struct ib_qp *qp) struct ib_cq *scq, *rcq; struct ib_srq *srq; struct ib_rwq_ind_table *ind_tbl; + struct ib_qp_security *sec; int ret; WARN_ON_ONCE(qp->mrs_used > 0); @@ -1341,6 +1358,9 @@ int ib_destroy_qp(struct ib_qp *qp) rcq = qp->recv_cq; srq = qp->srq; ind_tbl = qp->rwq_ind_tbl; + sec = qp->qp_sec; + if (sec) + ib_destroy_qp_security_begin(sec); if (!qp->uobject) rdma_rw_cleanup_mrs(qp); @@ -1357,6 +1377,11 @@ int ib_destroy_qp(struct ib_qp *qp) atomic_dec(&srq->usecnt); if (ind_tbl) atomic_dec(&ind_tbl->usecnt); + if (sec) + ib_destroy_qp_security_end(sec); + } else { + if (sec) + ib_destroy_qp_security_abort(sec); } return ret; diff --git a/include/linux/lsm_hooks.h b/include/linux/lsm_hooks.h index 558adfa..d576efc 100644 --- a/include/linux/lsm_hooks.h +++ b/include/linux/lsm_hooks.h @@ -8,6 +8,7 @@ * Copyright (C) 2001 Silicon Graphics, Inc. (Trust Technology Group) * Copyright (C) 2015 Intel Corporation. * Copyright (C) 2015 Casey Schaufler + * Copyright (C) 2016 Mellanox Techonologies * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -903,6 +904,21 @@ * associated with the TUN device's security structure. * @security pointer to the TUN devices's security structure. * + * Security hooks for Infiniband + * + * @ib_pkey_access: + * Check permission to access a pkey when modifing a QP. + * @subnet_prefix the subnet prefix of the port being used. + * @pkey the pkey to be accessed. + * @sec pointer to a security structure. + * @ib_alloc_security: + * Allocate a security structure for Infiniband objects. + * @sec pointer to a security structure pointer. + * Returns 0 on success, non-zero on failure + * @ib_free_security: + * Deallocate an Infiniband security structure. + * @sec contains the security structure to be freed. + * * Security hooks for XFRM operations. * * @xfrm_policy_alloc_security: @@ -1611,6 +1627,12 @@ union security_list_options { int (*tun_dev_open)(void *security); #endif /* CONFIG_SECURITY_NETWORK */ +#ifdef CONFIG_SECURITY_INFINIBAND + int (*ib_pkey_access)(void *sec, u64 subnet_prefix, u16 pkey); + int (*ib_alloc_security)(void **sec); + void (*ib_free_security)(void *sec); +#endif /* CONFIG_SECURITY_INFINIBAND */ + #ifdef CONFIG_SECURITY_NETWORK_XFRM int (*xfrm_policy_alloc_security)(struct xfrm_sec_ctx **ctxp, struct xfrm_user_sec_ctx *sec_ctx, @@ -1841,6 +1863,11 @@ struct security_hook_heads { struct list_head tun_dev_attach; struct list_head tun_dev_open; #endif /* CONFIG_SECURITY_NETWORK */ +#ifdef CONFIG_SECURITY_INFINIBAND + struct list_head ib_pkey_access; + struct list_head ib_alloc_security; + struct list_head ib_free_security; +#endif /* CONFIG_SECURITY_INFINIBAND */ #ifdef CONFIG_SECURITY_NETWORK_XFRM struct list_head xfrm_policy_alloc_security; struct list_head xfrm_policy_clone_security; diff --git a/include/linux/security.h b/include/linux/security.h index c2125e9..342ca4c 100644 --- a/include/linux/security.h +++ b/include/linux/security.h @@ -6,6 +6,7 @@ * Copyright (C) 2001 Networks Associates Technology, Inc * Copyright (C) 2001 James Morris * Copyright (C) 2001 Silicon Graphics, Inc. (Trust Technology Group) + * Copyright (C) 2016 Mellanox Techonologies * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1393,6 +1394,26 @@ static inline int security_tun_dev_open(void *security) } #endif /* CONFIG_SECURITY_NETWORK */ +#ifdef CONFIG_SECURITY_INFINIBAND +int security_ib_pkey_access(void *sec, u64 subnet_prefix, u16 pkey); +int security_ib_alloc_security(void **sec); +void security_ib_free_security(void *sec); +#else /* CONFIG_SECURITY_INFINIBAND */ +static inline int security_ib_pkey_access(void *sec, u64 subnet_prefix, u16 pkey) +{ + return 0; +} + +static inline int security_ib_alloc_security(void **sec) +{ + return 0; +} + +static inline void security_ib_free_security(void *sec) +{ +} +#endif /* CONFIG_SECURITY_INFINIBAND */ + #ifdef CONFIG_SECURITY_NETWORK_XFRM int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp, diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index db178fd..1143586 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -1511,6 +1511,45 @@ struct ib_rwq_ind_table_init_attr { struct ib_wq **ind_tbl; }; +enum port_pkey_state { + IB_PORT_PKEY_NOT_VALID = 0, + IB_PORT_PKEY_VALID = 1, + IB_PORT_PKEY_LISTED = 2, +}; + +struct ib_qp_security; + +struct ib_port_pkey { + enum port_pkey_state state; + u16 pkey_index; + u8 port_num; + struct list_head qp_list; + struct list_head to_error_list; + struct ib_qp_security *sec; +}; + +struct ib_ports_pkeys { + struct ib_port_pkey main; + struct ib_port_pkey alt; +}; + +struct ib_qp_security { + struct ib_qp *qp; + struct ib_device *dev; + /* Hold this mutex when changing port and pkey settings. */ + struct mutex mutex; + struct ib_ports_pkeys *ports_pkeys; + /* A list of all open shared QP handles. Required to enforce security + * properly for all users of a shared QP. + */ + struct list_head shared_qp_list; + void *security; + bool destroying; + atomic_t error_list_count; + struct completion error_complete; + int error_comps_pending; +}; + /* * @max_write_sge: Maximum SGE elements per RDMA WRITE request. * @max_read_sge: Maximum SGE elements per RDMA READ request. @@ -1540,6 +1579,7 @@ struct ib_qp { u32 max_read_sge; enum ib_qp_type qp_type; struct ib_rwq_ind_table *rwq_ind_tbl; + struct ib_qp_security *qp_sec; }; struct ib_mr { @@ -1820,6 +1860,12 @@ struct ib_port_immutable { u32 max_mad_size; }; +struct ib_port_pkey_list { + /* Lock to hold while modifying the list. */ + spinlock_t list_lock; + struct list_head pkey_list; +}; + struct ib_device { struct device *dma_device; @@ -1842,6 +1888,8 @@ struct ib_device { int num_comp_vectors; + struct ib_port_pkey_list *port_pkey_list; + struct iw_cm_verbs *iwcm; /** diff --git a/security/Kconfig b/security/Kconfig index 118f454..85cf893 100644 --- a/security/Kconfig +++ b/security/Kconfig @@ -49,6 +49,15 @@ config SECURITY_NETWORK implement socket and networking access controls. If you are unsure how to answer this question, answer N. +config SECURITY_INFINIBAND + bool "Infiniband Security Hooks" + depends on SECURITY && INFINIBAND + help + This enables the Infiniband security hooks. + If enabled, a security module can use these hooks to + implement Infiniband access controls. + If you are unsure how to answer this question, answer N. + config SECURITY_NETWORK_XFRM bool "XFRM (IPSec) Networking Security Hooks" depends on XFRM && SECURITY_NETWORK diff --git a/security/security.c b/security/security.c index f825304..7d3bf2f 100644 --- a/security/security.c +++ b/security/security.c @@ -4,6 +4,7 @@ * Copyright (C) 2001 WireX Communications, Inc * Copyright (C) 2001-2002 Greg Kroah-Hartman * Copyright (C) 2001 Networks Associates Technology, Inc + * Copyright (C) 2016 Mellanox Technologies * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1441,6 +1442,27 @@ EXPORT_SYMBOL(security_tun_dev_open); #endif /* CONFIG_SECURITY_NETWORK */ +#ifdef CONFIG_SECURITY_INFINIBAND + +int security_ib_pkey_access(void *sec, u64 subnet_prefix, u16 pkey) +{ + return call_int_hook(ib_pkey_access, 0, sec, subnet_prefix, pkey); +} +EXPORT_SYMBOL(security_ib_pkey_access); + +int security_ib_alloc_security(void **sec) +{ + return call_int_hook(ib_alloc_security, 0, sec); +} +EXPORT_SYMBOL(security_ib_alloc_security); + +void security_ib_free_security(void *sec) +{ + call_void_hook(ib_free_security, sec); +} +EXPORT_SYMBOL(security_ib_free_security); +#endif /* CONFIG_SECURITY_INFINIBAND */ + #ifdef CONFIG_SECURITY_NETWORK_XFRM int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp, @@ -1898,6 +1920,15 @@ struct security_hook_heads security_hook_heads = { LIST_HEAD_INIT(security_hook_heads.tun_dev_attach), .tun_dev_open = LIST_HEAD_INIT(security_hook_heads.tun_dev_open), #endif /* CONFIG_SECURITY_NETWORK */ + +#ifdef CONFIG_SECURITY_INFINIBAND + .ib_pkey_access = LIST_HEAD_INIT(security_hook_heads.ib_pkey_access), + .ib_alloc_security = + LIST_HEAD_INIT(security_hook_heads.ib_alloc_security), + .ib_free_security = + LIST_HEAD_INIT(security_hook_heads.ib_free_security), +#endif /* CONFIG_SECURITY_INFINIBAND */ + #ifdef CONFIG_SECURITY_NETWORK_XFRM .xfrm_policy_alloc_security = LIST_HEAD_INIT(security_hook_heads.xfrm_policy_alloc_security),