From patchwork Thu Jun 23 19:52:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Jurgens X-Patchwork-Id: 9195973 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 EC7D66075A for ; Thu, 23 Jun 2016 20:05:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DEA0C2846B for ; Thu, 23 Jun 2016 20:05:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D357428473; Thu, 23 Jun 2016 20:05:34 +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, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from emsm-gh1-uea10.nsa.gov (emsm-gh1-uea10.nsa.gov [8.44.101.8]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5679D2846B for ; Thu, 23 Jun 2016 20:05:34 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.26,518,1459814400"; d="scan'208";a="14966517" IronPort-PHdr: =?us-ascii?q?9a23=3AzeiWzBEgHq040SQC65C08p1GYnF86YWxBRYc798d?= =?us-ascii?q?s5kLTJ74oMSwAkXT6L1XgUPTWs2DsrQf2rKQ6/+rATFIyK3CmUhKSIZLWR4BhJ?= =?us-ascii?q?detC0bK+nBN3fGKuX3ZTcxBsVIWQwt1Xi6NU9IBJS2PAWK8TWM5DIfUi/yKRBy?= =?us-ascii?q?brysXNWD14LviKvqptX6WEZhvHKFe7R8LRG7/036l/I9ps9cEJs30QbDuXBSeu?= =?us-ascii?q?5blitCLFOXmAvgtI/rpMYwuxlKv7od0+IIEeCjJ+VrBYBfWT8mKWEu++XwsgTY?= =?us-ascii?q?CBCI4j0bSGpS2gJBHgzt9BjnWtL0tSzgu6x23yzeddb6VpgoSD+i6OFtUxauhy?= =?us-ascii?q?AZc3Y06GjNi9dYlKtBoQm5oxV0zsjTeo7RfPZ6c6/TeskWbXBMUsZYS2pKBYb4?= =?us-ascii?q?J5ACBuxHPetWs5jVpl0SoB/4Dg6pQKvvwzsOnHjt0Kshz+MqEinJ2QUhG5QFt3?= =?us-ascii?q?GHgs/yMfI+WOb97rTSwjjFdLsC1T776YXMcDgkrPWIVLR3YYzazkx5RFCNtUmZ?= =?us-ascii?q?tYGwZ2Dd7e8KqWXOqrM4WA=3D=3D?= X-IPAS-Result: =?us-ascii?q?A2H/BADUP2xX/wHyM5BdHQGDIIFTvCckhzJMAQEBAQEBAgJ?= =?us-ascii?q?iJ4IyghsCBAECNxQgCwMDCQEBFwghCAgDAS0VEQcHCwUYBIgPBMcrAQsBJI8GE?= =?us-ascii?q?QGFdwWOaYoWjjOJXIVGj35UgggcgU9riEuBNQEBAQ?= Received: from unknown (HELO tarius.tycho.ncsc.mil) ([144.51.242.1]) by emsm-gh1-uea10.nsa.gov with ESMTP; 23 Jun 2016 20:05:29 +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 u5NK5RBA005253; Thu, 23 Jun 2016 16:05:28 -0400 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 u5NJxxAN212585 for ; Thu, 23 Jun 2016 15:59:59 -0400 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 u5NJxxsM003689 for ; Thu, 23 Jun 2016 15:59:59 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A1AnBQAZP2xX/4GlL8FdHQGDIIFTuCuECYYYAoEvTAEBAQEBAWYnhE0CBHkQGAgxVwcSiDTHKgEBCCeVDwWOaYoWjjOJXIVGj35UgggcgU85MooAAQEB X-IPAS-Result: A1AnBQAZP2xX/4GlL8FdHQGDIIFTuCuECYYYAoEvTAEBAQEBAWYnhE0CBHkQGAgxVwcSiDTHKgEBCCeVDwWOaYoWjjOJXIVGj35UgggcgU85MooAAQEB X-IronPort-AV: E=Sophos;i="5.26,518,1459828800"; d="scan'208";a="5538197" Received: from emsm-gh1-uea10.corp.nsa.gov (HELO emsm-gh1-uea10.nsa.gov) ([10.208.41.36]) by goalie.tycho.ncsc.mil with ESMTP; 23 Jun 2016 15:59:43 -0400 IronPort-PHdr: =?us-ascii?q?9a23=3AkZY/bRw9W+oFo0TXCy+O+j09IxM/srCxBDY+r6Qd?= =?us-ascii?q?0OITIJqq85mqBkHD//Il1AaPBtSDraobwLKL+4nbGkU4qa6bt34DdJEeHzQksu?= =?us-ascii?q?4x2zIaPcieFEfgJ+TrZSFpVO5LVVti4m3peRMNQJW2WVTerzWI4CIIHV2nbEwu?= =?us-ascii?q?d7yzQtGZ15n//tvx0qWbWx9Piju5bOE6BzSNhiKViPMrh5B/IL060BrDrygAUe?= =?us-ascii?q?1XwWR1OQDbxE6ktY+YtaRu+CVIuv8n69UIEeCjJ/x5HvRkC2EtM3o0/9LDrh7e?= =?us-ascii?q?Vk6U4X9aVX8Z1lJQChXBxAnzQ5O0tyz9rOc70y6feYXtQascRSWp76AtTgThzi?= =?us-ascii?q?gAKXpx/XnekM1rpLpSuhO6vxh2yIOSZ5uacLJyeq7Rc9QASUJbU8pRXjAHCYS5?= =?us-ascii?q?K8MUAuMHe+ZVoZXsj1oIsRa6QwKrAaenyjZMwGXxxqA8yPgmGgLu0wkpHtZIu3?= =?us-ascii?q?PR//vvM6JHfemzhIvV1zrOaegejTv07onFdhIJpPyIWbt2dtqXwk4qQVCWxm6M?= =?us-ascii?q?oJDoamvGnt8GtHKWuq85Dbqi?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0H/BACrPmxX/4GlL8FdHQGDIIFTuCuEC?= =?us-ascii?q?YYYAoEvTAEBAQEBAQICYieCMoIbAgR5EBgIMVcHEog0xzEBAQgnlQ8FjmmKFo4?= =?us-ascii?q?ziVyFRo9+VIIIHIFPOTKKAAEBAQ?= X-IPAS-Result: =?us-ascii?q?A0H/BACrPmxX/4GlL8FdHQGDIIFTuCuECYYYAoEvTAEBAQE?= =?us-ascii?q?BAQICYieCMoIbAgR5EBgIMVcHEog0xzEBAQgnlQ8FjmmKFo4ziVyFRo9+VIIIH?= =?us-ascii?q?IFPOTKKAAEBAQ?= X-IronPort-AV: E=Sophos;i="5.26,518,1459814400"; d="scan'208";a="14966038" Received: from unknown (HELO mellanox.co.il) ([193.47.165.129]) by emsm-gh1-uea10.nsa.gov with ESMTP; 23 Jun 2016 19:59:41 +0000 Received: from Internal Mail-Server by MTLPINE1 (envelope-from danielj@mellanox.com) with ESMTPS (AES256-SHA encrypted); 23 Jun 2016 22:53:56 +0300 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 u5NJr2DL029223; Thu, 23 Jun 2016 22:53:54 +0300 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 12/12] IB/core: Implement the Infiniband flush callback Date: Thu, 23 Jun 2016 22:52:58 +0300 Message-Id: <1466711578-64398-13-git-send-email-danielj@mellanox.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1466711578-64398-1-git-send-email-danielj@mellanox.com> References: <1466711578-64398-1-git-send-email-danielj@mellanox.com> X-Mailman-Approved-At: Thu, 23 Jun 2016 16:01:54 -0400 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 Register the callback at init and unregister it at cleanup. When called walk the device list and call ib_security_cache_change for each port on each device. Signed-off-by: Daniel Jurgens Reviewed-by: Eli Cohen Reviewed-by: Leon Romanovsky --- drivers/infiniband/core/device.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c index 63deb5c..5060a7f 100644 --- a/drivers/infiniband/core/device.c +++ b/drivers/infiniband/core/device.c @@ -335,6 +335,29 @@ static int setup_port_pkey_list(struct ib_device *device) return 0; } +static void ib_security_flush(void) +{ + struct ib_device *dev; + + down_read(&lists_rwsem); + list_for_each_entry(dev, &device_list, core_list) { + int i; + + for (i = rdma_start_port(dev); i <= rdma_end_port(dev); i++) { + u64 sp; + int ret = ib_get_cached_subnet_prefix(dev, + i, + &sp); + + WARN_ONCE(ret, + "ib_get_cached_subnet_prefix err: %d, this should never happen here\n", + ret); + ib_security_cache_change(dev, i, sp); + } + } + up_read(&lists_rwsem); +} + /** * ib_register_device - Register an IB device with IB core * @device:Device to register @@ -1062,6 +1085,8 @@ static int __init ib_core_init(void) goto err_sa; } + security_register_ib_flush_callback(&ib_security_flush); + ib_cache_setup(); return 0; @@ -1085,6 +1110,7 @@ err: static void __exit ib_core_cleanup(void) { + security_unregister_ib_flush_callback(); ib_cache_cleanup(); ib_remove_ibnl_clients(); ib_sa_cleanup();