summaryrefslogtreecommitdiffstats
path: root/security/selinux/hooks.c
diff options
context:
space:
mode:
authorDaniel Jurgens <danielj@mellanox.com>2017-05-19 08:48:56 -0400
committerPaul Moore <paul@paul-moore.com>2017-05-23 12:27:41 -0400
commit3a976fa6767f3edebbf43839b686efaf71b8dee1 (patch)
treeb3f4df141cd3dfa1997337302019e18344270ccf /security/selinux/hooks.c
parenta806f7a1616f29b80749d708115a643c1f4ba056 (diff)
selinux: Allocate and free infiniband security hooks
Implement and attach hooks to allocate and free Infiniband object security structures. Signed-off-by: Daniel Jurgens <danielj@mellanox.com> Reviewed-by: James Morris <james.l.morris@oracle.com> Acked-by: Doug Ledford <dledford@redhat.com> Signed-off-by: Paul Moore <paul@paul-moore.com>
Diffstat (limited to 'security/selinux/hooks.c')
-rw-r--r--security/selinux/hooks.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index b005acbcc6e9..062b459b62bf 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -17,6 +17,7 @@
17 * Paul Moore <paul@paul-moore.com> 17 * Paul Moore <paul@paul-moore.com>
18 * Copyright (C) 2007 Hitachi Software Engineering Co., Ltd. 18 * Copyright (C) 2007 Hitachi Software Engineering Co., Ltd.
19 * Yuichi Nakamura <ynakam@hitachisoft.jp> 19 * Yuichi Nakamura <ynakam@hitachisoft.jp>
20 * Copyright (C) 2016 Mellanox Technologies
20 * 21 *
21 * This program is free software; you can redistribute it and/or modify 22 * This program is free software; you can redistribute it and/or modify
22 * it under the terms of the GNU General Public License version 2, 23 * it under the terms of the GNU General Public License version 2,
@@ -6144,7 +6145,26 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
6144 *_buffer = context; 6145 *_buffer = context;
6145 return rc; 6146 return rc;
6146} 6147}
6148#endif
6149
6150#ifdef CONFIG_SECURITY_INFINIBAND
6151static int selinux_ib_alloc_security(void **ib_sec)
6152{
6153 struct ib_security_struct *sec;
6154
6155 sec = kzalloc(sizeof(*sec), GFP_KERNEL);
6156 if (!sec)
6157 return -ENOMEM;
6158 sec->sid = current_sid();
6159
6160 *ib_sec = sec;
6161 return 0;
6162}
6147 6163
6164static void selinux_ib_free_security(void *ib_sec)
6165{
6166 kfree(ib_sec);
6167}
6148#endif 6168#endif
6149 6169
6150static struct security_hook_list selinux_hooks[] __lsm_ro_after_init = { 6170static struct security_hook_list selinux_hooks[] __lsm_ro_after_init = {
@@ -6331,7 +6351,10 @@ static struct security_hook_list selinux_hooks[] __lsm_ro_after_init = {
6331 LSM_HOOK_INIT(tun_dev_attach_queue, selinux_tun_dev_attach_queue), 6351 LSM_HOOK_INIT(tun_dev_attach_queue, selinux_tun_dev_attach_queue),
6332 LSM_HOOK_INIT(tun_dev_attach, selinux_tun_dev_attach), 6352 LSM_HOOK_INIT(tun_dev_attach, selinux_tun_dev_attach),
6333 LSM_HOOK_INIT(tun_dev_open, selinux_tun_dev_open), 6353 LSM_HOOK_INIT(tun_dev_open, selinux_tun_dev_open),
6334 6354#ifdef CONFIG_SECURITY_INFINIBAND
6355 LSM_HOOK_INIT(ib_alloc_security, selinux_ib_alloc_security),
6356 LSM_HOOK_INIT(ib_free_security, selinux_ib_free_security),
6357#endif
6335#ifdef CONFIG_SECURITY_NETWORK_XFRM 6358#ifdef CONFIG_SECURITY_NETWORK_XFRM
6336 LSM_HOOK_INIT(xfrm_policy_alloc_security, selinux_xfrm_policy_alloc), 6359 LSM_HOOK_INIT(xfrm_policy_alloc_security, selinux_xfrm_policy_alloc),
6337 LSM_HOOK_INIT(xfrm_policy_clone_security, selinux_xfrm_policy_clone), 6360 LSM_HOOK_INIT(xfrm_policy_clone_security, selinux_xfrm_policy_clone),