From: Dan Jurgens <danielj@mellanox.com>
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
Cc: selinux@tycho.nsa.gov, linux-security-module@vger.kernel.org,
linux-rdma@vger.kernel.org, yevgenyp@mellanox.com,
Daniel Jurgens <danielj@mellanox.com>
Subject: [PATCH v7 1/9] IB/core: IB cache enhancements to support Infiniband security
Date: Fri, 19 May 2017 15:48:51 +0300 [thread overview]
Message-ID: <1495198139-69993-2-git-send-email-danielj@mellanox.com> (raw)
In-Reply-To: <1495198139-69993-1-git-send-email-danielj@mellanox.com>
From: Daniel Jurgens <danielj@mellanox.com>
Cache the subnet prefix and add a function to access it. Enforcing
security requires frequent queries of the subnet prefix and the pkeys in
the pkey table.
Signed-off-by: Daniel Jurgens <danielj@mellanox.com>
Reviewed-by: Eli Cohen <eli@mellanox.com>
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
---
v2:
- In ib_get_cached_subnet_prefix wait to initialize p until after
validation. Yuval Shaia
drivers/infiniband/core/cache.c | 22 ++++++++++++++++++++++
drivers/infiniband/core/core_priv.h | 3 +++
include/rdma/ib_verbs.h | 1 +
3 files changed, 26 insertions(+)
diff --git a/drivers/infiniband/core/cache.c b/drivers/infiniband/core/cache.c
index b1371eb..b9c0066 100644
--- a/drivers/infiniband/core/cache.c
+++ b/drivers/infiniband/core/cache.c
@@ -911,6 +911,26 @@ int ib_get_cached_pkey(struct ib_device *device,
}
EXPORT_SYMBOL(ib_get_cached_pkey);
+int ib_get_cached_subnet_prefix(struct ib_device *device,
+ u8 port_num,
+ u64 *sn_pfx)
+{
+ unsigned long flags;
+ int p;
+
+ if (port_num < rdma_start_port(device) ||
+ port_num > rdma_end_port(device))
+ return -EINVAL;
+
+ p = port_num - rdma_start_port(device);
+ read_lock_irqsave(&device->cache.lock, flags);
+ *sn_pfx = device->cache.ports[p].subnet_prefix;
+ read_unlock_irqrestore(&device->cache.lock, flags);
+
+ return 0;
+}
+EXPORT_SYMBOL(ib_get_cached_subnet_prefix);
+
int ib_find_cached_pkey(struct ib_device *device,
u8 port_num,
u16 pkey,
@@ -1108,6 +1128,8 @@ static void ib_cache_update(struct ib_device *device,
device->cache.ports[port - rdma_start_port(device)].port_state =
tprops->state;
+ device->cache.ports[port - rdma_start_port(device)].subnet_prefix =
+ tprops->subnet_prefix;
write_unlock_irq(&device->cache.lock);
kfree(gid_cache);
diff --git a/drivers/infiniband/core/core_priv.h b/drivers/infiniband/core/core_priv.h
index cb7d372..249e3ed 100644
--- a/drivers/infiniband/core/core_priv.h
+++ b/drivers/infiniband/core/core_priv.h
@@ -176,4 +176,7 @@ int ib_nl_handle_set_timeout(struct sk_buff *skb,
int ib_nl_handle_ip_res_resp(struct sk_buff *skb,
struct netlink_callback *cb);
+int ib_get_cached_subnet_prefix(struct ib_device *device,
+ u8 port_num,
+ u64 *sn_pfx);
#endif /* _CORE_PRIV_H */
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 99e4423..23486d3 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -1841,6 +1841,7 @@ enum ib_mad_result {
#define IB_DEVICE_NAME_MAX 64
struct ib_port_cache {
+ u64 subnet_prefix;
struct ib_pkey_cache *pkey;
struct ib_gid_table *gid;
u8 lmc;
--
2.7.4
next prev parent reply other threads:[~2017-05-19 12:48 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-19 12:48 [PATCH v7 0/9] SELinux support for Infiniband RDMA Dan Jurgens
2017-05-19 12:48 ` Dan Jurgens [this message]
2017-05-21 23:56 ` [PATCH v7 1/9] IB/core: IB cache enhancements to support Infiniband security James Morris
2017-05-19 12:48 ` [PATCH v7 2/9] IB/core: Enforce PKey security on QPs Dan Jurgens
[not found] ` <1495198139-69993-3-git-send-email-danielj-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2017-05-19 19:13 ` Paul Moore
2017-05-22 0:13 ` James Morris
2017-05-22 10:42 ` Daniel Jurgens
[not found] ` <VI1PR05MB167814F66EEF8A1BD77C793AC4F80-79XLn2atqDOzmZAjKwT+HdqRiQSDpxhJvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2017-05-22 20:59 ` Paul Moore
2017-05-19 12:48 ` [PATCH v7 5/9] selinux: Create policydb version for Infiniband support Dan Jurgens
2017-05-22 0:24 ` James Morris
2017-05-19 12:48 ` [PATCH v7 7/9] selinux: Implement Infiniband PKey "Access" access vector Dan Jurgens
[not found] ` <1495198139-69993-8-git-send-email-danielj-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2017-05-22 0:31 ` James Morris
[not found] ` <1495198139-69993-1-git-send-email-danielj-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2017-05-19 12:48 ` [PATCH v7 3/9] selinux lsm IB/core: Implement LSM notification system Dan Jurgens
2017-05-22 0:15 ` James Morris
2017-05-19 12:48 ` [PATCH v7 4/9] IB/core: Enforce security on management datagrams Dan Jurgens
2017-05-19 19:21 ` Paul Moore
2017-05-19 23:57 ` Daniel Jurgens
2017-05-19 12:48 ` [PATCH v7 6/9] selinux: Allocate and free infiniband security hooks Dan Jurgens
2017-05-22 0:26 ` James Morris
2017-05-19 12:48 ` [PATCH v7 8/9] selinux: Add IB Port SMP access vector Dan Jurgens
[not found] ` <1495198139-69993-9-git-send-email-danielj-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2017-05-22 0:32 ` James Morris
2017-05-19 12:48 ` [PATCH v7 9/9] selinux: Add a cache for quicker retreival of PKey SIDs Dan Jurgens
2017-05-19 16:47 ` [PATCH v7 0/9] SELinux support for Infiniband RDMA Daniel Jurgens
2017-05-19 19:35 ` Paul Moore
2017-05-20 0:10 ` Daniel Jurgens
[not found] ` <CAHC9VhQtw4fFrCdKcznHrLDkAJVDhi=y9dYMxtOP23XVKq+rCw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-05-20 11:56 ` Doug Ledford
2017-05-22 0:35 ` James Morris
2017-05-22 10:50 ` Daniel Jurgens
[not found] ` <alpine.LRH.2.20.1705221033550.3502-gx6/JNMH7DfYtjvyW6yDsg@public.gmane.org>
2017-05-22 19:14 ` Paul Moore
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1495198139-69993-2-git-send-email-danielj@mellanox.com \
--to=danielj@mellanox.com \
--cc=chrisw@sous-sol.org \
--cc=dledford@redhat.com \
--cc=eparis@parisplace.org \
--cc=hal.rosenstock@gmail.com \
--cc=linux-rdma@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=paul@paul-moore.com \
--cc=sds@tycho.nsa.gov \
--cc=sean.hefty@intel.com \
--cc=selinux@tycho.nsa.gov \
--cc=yevgenyp@mellanox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox