selinux: move ibpkeys code under CONFIG_SECURITY_INFINIBAND.
PATCH 1/1 selinux: move ibpkeys code under CONFIG_SECURITY_INFINIBAND.
Updated the subject to reflect the change .
-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Ravi Kumar Siddojigari
Sent: Tuesday, December 17, 2019 8:42 PM
To: 'Paul Moore' <[email protected]>
Cc: [email protected]
Subject: RE: [PATCH] selinux: move pkey sid cache based retrieval under defconfig
Yes Paul, it should be under CONFIG_SECURITY_INFINIBAND thanks for correcting this . Hope we can taken it fwd as all the targets with disabled InfiniBand can be gained . Please find the updated path for review .
From 6a8c60eacd0b6e5189722bb1823864b6728c2e34 Mon Sep 17 00:00:00 2001
From: Ravi Kumar Siddojigari <[email protected]>
Date: Wed, 11 Dec 2019 19:57:24 +0530
Subject: [PATCH] selinux: move ibpkeys code under CONFIG_SECURITY_INFINIBAND.
Move cache based pkey sid retrieval code which was added with Commit 409dcf31. under CONFIG_SECURITY_INFINIBAND. As its going to alloc a new cache which may impact low ram devices which was enabled by default.
--- security/selinux/Makefile | 4 +++- security/selinux/hooks.c | 6 ++++++ security/selinux/include/objsec.h | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-)
security/selinux/Makefile +3 -1
@@ -6,12 +6,14 @@ obj-$(CONFIG_SECURITY_SELINUX) := selinux.o selinux-y := avc.o hooks.o selinuxfs.o netlink.o nlmsgtab.o netif.o \ - netnode.o netport.o ibpkey.o exports.o \ + netnode.o netport.o exports.o \ ss/ebitmap.o ss/hashtab.o ss/symtab.o ss/sidtab.o ss/avtab.o \ ss/policydb.o ss/services.o ss/conditional.o ss/mls.o ss/status.o selinux-$(CONFIG_SECURITY_NETWORK_XFRM) += xfrm.o +selinux-$(CONFIG_SECURITY_INFINIBAND) += ibpkey.o + selinux-$(CONFIG_NETLABEL) += netlabel.o ccflags-y := -I$(srctree)/security/selinux -I$(srctree)/security/selinux/include
security/selinux/hooks.c +6 -0
@@ -94,7 +94,11 @@#include "netif.h" #include "netnode.h" #include "netport.h" + +#ifdef CONFIG_SECURITY_INFINIBAND #include "ibpkey.h" +#endif +#include "xfrm.h" #include "netlabel.h" #include "audit.h"
@@ -198,7 +202,9 @@ static int selinux_netcache_avc_callback(u32 event) static int selinux_lsm_notifier_avc_callback(u32 event) {if (event ==AVC_CALLBACK_RESET ) { +#ifdef CONFIG_SECURITY_INFINIBAND sel_ib_pkey_flush (); +#endif call_lsm_notifier (LSM_POLICY_CHANGE ,NULL ); }
security/selinux/include/objsec.h +2 -0
@@ -149,11 +149,13 @@ struct ib_security_struct {u32 sid;/* SID of the queue pair or MAD agent */ }; +#ifdef CONFIG_SECURITY_INFINIBAND struct pkey_security_struct {u64 subnet_prefix;/* Port subnet prefix */ u16 pkey;/* PKey number */ u32 sid;/* SID of pkey */ }; +#endif struct bpf_security_struct {u32 sid;/*SID of bpf obj creater*/
--
1.9.1
Regards,
Ravi
-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Paul Moore
Sent: Monday, December 16, 2019 7:56 PM
To: Ravi Kumar Siddojigari <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH] selinux: move pkey sid cache based retrieval under defconfig
Quoted 10 lines · Ravi Kumar Siddojigari
Hi Team,
We see an increase in the memory consumption from 4.9 ->4.19 kernel which is impacting thelow_ramdevice .
So thought of enabling only that are really needed for the such device where performance might not be of priority list .
One such patch is on the pkey sid cache which was added with commit :"409dcf31"
which can be moved under defconfig where enabled by default and only disabled forlow_ramtargets.
Which is going to save ram/reduce slub usage .
Why not just reuse CONFIG_SECURITY_INFINIBAND? I'm guessing these systems are using the SELinux/IB controls at all, so why not remove them completely?
--
paul moore
www.paul-moore.com
Paul Moore
maintainerQuoted 26 lines · Ravi Kumar Siddojigari
-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Ravi Kumar Siddojigari
Sent: Tuesday, December 17, 2019 8:42 PM
To: 'Paul Moore' <[email protected]>
Cc: [email protected]
Subject: RE: [PATCH] selinux: move pkey sid cache based retrieval under defconfigYes Paul, it should be under
CONFIG_SECURITY_INFINIBANDthanks for correcting this . Hope we can taken it fwd as all the targets with disabled InfiniBand can be gained . Please find the updated path for review .From
6a8c60eacd0b6e5189722bb1823864b6728c2e34Mon Sep 17 00:00:00 2001
From: Ravi Kumar Siddojigari <[email protected]>
Date: Wed, 11 Dec 2019 19:57:24 +0530
Subject: [PATCH] selinux: move ibpkeys code underCONFIG_SECURITY_INFINIBAND.Move cache based pkey sid retrieval code which was added with Commit
409dcf31. underCONFIG_SECURITY_INFINIBAND. As its going to alloc a new cache which may impact low ram devices which was enabled by default.Change-Id I80a13fb7bce8723c8c880cb77cbaee42db413a7aSigned-off-by Ravi Kumar Siddojigari <[email protected]>--- security/selinux/Makefile | 4 +++- security/selinux/hooks.c | 6 ++++++ security/selinux/include/objsec.h | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-)
...
security/selinux/hooks.c line 100
Quoted 11 lines
security/selinux/hooks.c +3
-0@@ -94,7 +94,11 @@#include "netif.h" #include "netnode.h" #include "netport.h" + +#ifdef CONFIG_SECURITY_INFINIBAND #include "ibpkey.h" +#endif
See the comments below ...
security/selinux/hooks.c static int selinux_netcache_avc_callback(u32 event) static int selinux_lsm_notifier_avc_callback(u32 event) { · line 207
Quoted 10 lines
security/selinux/hooks.c +2
-0#include "xfrm.h" #include "netlabel.h" #include "audit.h" @@ -198,7 +202,9 @@ static int selinux_netcache_avc_callback(u32 event) static int selinux_lsm_notifier_avc_callback(u32 event) {if (event ==AVC_CALLBACK_RESET ) { +#ifdef CONFIG_SECURITY_INFINIBAND sel_ib_pkey_flush (); +#endif call_lsm_notifier (LSM_POLICY_CHANGE ,NULL ); }
In cases like the you see directly above, and in the #include further up, the kernel usually solves this by creating dummy function in the header file. In this case, ibpkey.h would look something like this:
Quoted 1 line
Quoted 1 line
Quoted 1 line
/* header comments, blah blah blah */
#ifndef _SELINUX_IB_PKEY_H
#define _SELINUX_IB_PKEY_H
#ifdef CONFIG_SECURITY_INFINIBAND
void sel_ib_pkey_flush(void);
int sel_ib_pkey_sid(u64 subnet_prefix, u16 pkey, u32 *sid); #else
static inline void sel_ib_pkey_flush(void)
{
return;
}
static inline int sel_ib_pkey_sid(u64 subnet_prefix, u16 pkey, u32 *sid) {
*sid = SECINITSID_UNLABELED;
return 0;
}
#endif
#endif
Quoted 1 line
Quoted 1 line
Quoted 1 line
Does that make sense?
--
paul moore
www.paul-moore.com
Updated the path , moved header file also under the config key which was missed out in earlier patch. --
From a53941d36621ccb53fba900cb9a762dded41dc96 Mon Sep 17 00:00:00 2001
From: Ravi Kumar Siddojigari <[email protected]>
Date: Wed, 11 Dec 2019 19:57:24 +0530
Subject: [PATCH] selinux: move ibpkeys code under CONFIG_SECURITY_INFINIBAND.
Move cache based pkey sid retrieval code which was added with Commit 409dcf31. under CONFIG_SECURITY_INFINIBAND. As its going to alloc a new cache which may impact low ram devices which was enabled by default.
--- security/selinux/Makefile | 4 +++- security/selinux/hooks.c | 6 ++++++ security/selinux/include/ibpkey.h | 2 ++ security/selinux/include/objsec.h | 2 ++ 4 files changed, 13 insertions(+), 1 deletion(-)
security/selinux/Makefile +3 -1
@@ -6,12 +6,14 @@ obj-$(CONFIG_SECURITY_SELINUX) := selinux.o selinux-y := avc.o hooks.o selinuxfs.o netlink.o nlmsgtab.o netif.o \ - netnode.o netport.o ibpkey.o exports.o \ + netnode.o netport.o exports.o \ ss/ebitmap.o ss/hashtab.o ss/symtab.o ss/sidtab.o ss/avtab.o \ ss/policydb.o ss/services.o ss/conditional.o ss/mls.o ss/status.o selinux-$(CONFIG_SECURITY_NETWORK_XFRM) += xfrm.o +selinux-$(CONFIG_SECURITY_INFINIBAND) += ibpkey.o + selinux-$(CONFIG_NETLABEL) += netlabel.o ccflags-y := -I$(srctree)/security/selinux -I$(srctree)/security/selinux/include
security/selinux/hooks.c +6 -0
@@ -94,7 +94,11 @@#include "netif.h" #include "netnode.h" #include "netport.h" + +#ifdef CONFIG_SECURITY_INFINIBAND #include "ibpkey.h" +#endif +#include "xfrm.h" #include "netlabel.h" #include "audit.h"
@@ -198,7 +202,9 @@ static int selinux_netcache_avc_callback(u32 event)static int selinux_lsm_notifier_avc_callback (u32 event) {if (event ==AVC_CALLBACK_RESET ) { +#ifdef CONFIG_SECURITY_INFINIBAND sel_ib_pkey_flush (); +#endif call_lsm_notifier (LSM_POLICY_CHANGE ,NULL ); }
security/selinux/include/ibpkey.h +2 -0
@@ -24,8 +24,10 @@#ifndef _SELINUX_IB_PKEY_H#define _SELINUX_IB_PKEY_H +#ifdef CONFIG_SECURITY_INFINIBAND void sel_ib_pkey_flush (void );int sel_ib_pkey_sid (u64 subnet_prefix,u16 pkey,u32 *sid);#endif +#endif
security/selinux/include/objsec.h +2 -0
@@ -149,11 +149,13 @@ struct ib_security_struct {u32 sid;/* SID of the queue pair or MAD agent */ }; +#ifdef CONFIG_SECURITY_INFINIBAND struct pkey_security_struct {u64 subnet_prefix;/* Port subnet prefix */ u16 pkey;/* PKey number */ u32 sid;/* SID of pkey */ }; +#endif struct bpf_security_struct {u32 sid;/*SID of bpf obj creater*/
Signature · 4 lines
1.9.1 Br,
-----Original Message-----
From: Paul Moore <[email protected]>
Sent: Thursday, December 19, 2019 7:39 AM
To: Ravi Kumar Siddojigari <[email protected]>
Cc: [email protected]; Stephen Smalley <[email protected]>
Subject: Re: [PATCH] selinux: move ibpkeys code under CONFIG_SECURITY_INFINIBAND.
Quoted 28 lines · Ravi Kumar Siddojigari
-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Ravi Kumar Siddojigari
Sent: Tuesday, December 17, 2019 8:42 PM
To: 'Paul Moore' <[email protected]>
Cc: [email protected]
Subject: RE: [PATCH] selinux: move pkey sid cache based retrieval under defconfigYes Paul, it should be under
CONFIG_SECURITY_INFINIBANDthanks for correcting this . Hope we can taken it fwd as all the targets with disabled InfiniBand can be gained . Please find the updated path for review .From
6a8c60eacd0b6e5189722bb1823864b6728c2e34Mon Sep 17 00:00:00 2001
From: Ravi Kumar Siddojigari <[email protected]>
Date: Wed, 11 Dec 2019 19:57:24 +0530
Subject: [PATCH] selinux: move ibpkeys code underCONFIG_SECURITY_INFINIBAND.Move cache based pkey sid retrieval code which was added with Commit
409dcf31. underCONFIG_SECURITY_INFINIBAND. As its going to alloc a new cache which may impact low ram devices which was enabled by default.Change-Id I80a13fb7bce8723c8c880cb77cbaee42db413a7aSigned-off-by Ravi Kumar Siddojigari <[email protected]>--- security/selinux/Makefile | 4 +++- security/selinux/hooks.c | 6 ++++++ security/selinux/include/objsec.h | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-)
...
security/selinux/hooks.c line 100
Quoted 12 lines
security/selinux/hooks.c index renamed from security/selinux/hooks.c +0
-0b1a9ac9..157faaf 100644
security/selinux/hooks.c +3
-0@@ -94,7 +94,11 @@#include "netif.h" #include "netnode.h" #include "netport.h" + +#ifdef CONFIG_SECURITY_INFINIBAND #include "ibpkey.h" +#endif
See the comments below ...
security/selinux/hooks.c static int selinux_netcache_avc_callback(u32 event) static int selinux_lsm_notifier_avc_callback(u32 event) { · line 207
Quoted 10 lines
security/selinux/hooks.c +2
-0#include "xfrm.h" #include "netlabel.h" #include "audit.h" @@ -198,7 +202,9 @@ static int selinux_netcache_avc_callback(u32 event) static int selinux_lsm_notifier_avc_callback(u32 event) {if (event ==AVC_CALLBACK_RESET ) { +#ifdef CONFIG_SECURITY_INFINIBAND sel_ib_pkey_flush (); +#endif call_lsm_notifier (LSM_POLICY_CHANGE ,NULL ); }
In cases like the you see directly above, and in the #include further up, the kernel usually solves this by creating dummy function in the header file. In this case, ibpkey.h would look something like this:
Quoted 1 line
Quoted 1 line
Quoted 1 line
/* header comments, blah blah blah */
#ifndef _SELINUX_IB_PKEY_H
#define _SELINUX_IB_PKEY_H
#ifdef CONFIG_SECURITY_INFINIBAND
void sel_ib_pkey_flush(void);
int sel_ib_pkey_sid(u64 subnet_prefix, u16 pkey, u32 *sid); #else static inline void sel_ib_pkey_flush(void) {
return;
}
static inline int sel_ib_pkey_sid(u64 subnet_prefix, u16 pkey, u32 *sid) {
*sid = SECINITSID_UNLABELED;
return 0;
}
#endif
#endif
Quoted 1 line
Quoted 1 line
Quoted 1 line
Does that make sense?
--
paul moore
www.paul-moore.com