Skip to contentSkip to conversation

selinuxns: mark init_selinux_ns as __ro_after_init

RFC PATCH In review James Morris 2 participants 2 messages Oct 16, 2017 SELinux security module

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 selinuxns: mark init_selinux_ns as __ro_after_init

This is a patch against the SELinux namespace work.

Mark the initial SELinux namespace pointer as __ro_after_init, to harden against malicious overwrite by an attacker.

---
 security/selinux/hooks.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
security/selinux/hooks.c +1 -1
index 3daad14..98dbf57 100644
@@ -97,7 +97,7 @@
 #include "audit.h"
 #include "avc_ss.h"
 
-struct selinux_ns *init_selinux_ns;
+struct selinux_ns *init_selinux_ns __ro_after_init;
 
 /* SECMARK reference count */
 static atomic_t selinux_secmark_refcount = ATOMIC_INIT(0);
Signature · 6 lines
1.8.3.1


-- 
James Morris
<[email protected]>
#1 lore raw
Quoted 7 lines · James Morris

This is a patch against the SELinux namespace work.

Mark the initial SELinux namespace pointer as __ro_after_init, to harden
against malicious overwrite by an attacker.

Thanks, this looks fine; I can apply it on my branch if you want. Note however that at this point, I am looking more for design discussion and resolution of the problems noted in the patch descriptions for the existing patches, and anticipate many of those patches being substantially rewritten or discarded in any final versiopn. This particular patch however could likely be rebased on top of the first patch in the series and wouldn't be affected by such changes.

Quoted 21 lines

---
 security/selinux/hooks.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
security/selinux/hooks.c +0 -0
index 3daad14..98dbf57 100644
@@ -97,7 +97,7 @@
  #include "audit.h"
  #include "avc_ss.h"

security/selinux/hooks.c +1 -1
-struct selinux_ns *init_selinux_ns;
+struct selinux_ns *init_selinux_ns __ro_after_init;


 /* SECMARK reference count */
 static atomic_t selinux_secmark_refcount = ATOMIC_INIT(0); --
1.8.3.1