Skip to contentSkip to conversation

semanage: correct fcontext auditing

PATCH Applied Miroslav Vadkerti 4 participants 8 messages Aug 12, 2016 – Aug 15, 2016 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 semanage: correct fcontext auditing

For modify action actually audit the selinux type, i.e. use setype variable.

For deleting equal fcontext rules do not audit ftype, as the ftype value for equal rules makes little sense.

---
 policycoreutils/semanage/seobject.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
policycoreutils/semanage/seobject.py +2 -2
index 786ed0e..8d3088c 100644
@@ -1992,7 +1992,7 @@ class fcontextRecords(semanageRecords):
         if not seuser:
             seuser = "system_u"
 
-        self.mylog.log_change("resrc=fcontext op=modify %s ftype=%s tcontext=%s:%s:%s:%s" % (audit.audit_encode_nv_string("tglob", target, 0), ftype_to_audit[ftype], seuser, "object_r", type, serange))
+        self.mylog.log_change("resrc=fcontext op=modify %s ftype=%s tcontext=%s:%s:%s:%s" % (audit.audit_encode_nv_string("tglob", target, 0), ftype_to_audit[ftype], seuser, "object_r", setype, serange))
 
     def modify(self, target, setype, ftype, serange, seuser):
         self.begin()
@@ -2030,7 +2030,7 @@ class fcontextRecords(semanageRecords):
             self.equiv.pop(target)
             self.equal_ind = True
 
-            self.mylog.log_change("resrc=fcontext op=delete-equal %s ftype=%s" % (audit.audit_encode_nv_string("tglob", target, 0), ftype_to_audit[ftype]))
+            self.mylog.log_change("resrc=fcontext op=delete-equal %s" % (audit.audit_encode_nv_string("tglob", target, 0)))
 
             return
 
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 16 lines · Miroslav Vadkerti

For modify action actually audit the selinux type, i.e. use setype variable.

For deleting equal fcontext rules do not audit ftype, as the ftype value for equal rules makes little sense.

---
 policycoreutils/semanage/seobject.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
policycoreutils/semanage/seobject.py +0 -0
index 786ed0e..8d3088c 100644

policycoreutils/semanage/seobject.py class fcontextRecords(semanageRecords): · line 1993

Quoted 2 lines
policycoreutils/semanage/seobject.py +0 -0
@@ -1992,7 +1992,7 @@ class fcontextRecords(semanageRecords):
         if not seuser:
             seuser = "system_u"

system_u is reference policy specific. this is selinux user space not reference policy user space.

Quoted 16 lines
policycoreutils/semanage/seobject.py +2 -2
-        self.mylog.log_change("resrc=fcontext op=modify %s ftype=%s tcontext=%s:%s:%s:%s" % (audit.audit_encode_nv_string("tglob", target, 0), ftype_to_audit[ftype], seuser, "object_r", type, serange))
+        self.mylog.log_change("resrc=fcontext op=modify %s ftype=%s tcontext=%s:%s:%s:%s" % (audit.audit_encode_nv_string("tglob", target, 0), ftype_to_audit[ftype], seuser, "object_r", setype, serange))
 
     def modify(self, target, setype, ftype, serange, seuser):
         self.begin()
@@ -2030,7 +2030,7 @@ class fcontextRecords(semanageRecords):
             self.equiv.pop(target)
             self.equal_ind = True
 
-            self.mylog.log_change("resrc=fcontext op=delete-equal %s ftype=%s" % (audit.audit_encode_nv_string("tglob", target, 0), ftype_to_audit[ftype]))
+            self.mylog.log_change("resrc=fcontext op=delete-equal %s" % (audit.audit_encode_nv_string("tglob", target, 0)))
 
             return
 
Signature · 3 lines
Key fingerprint = 5F4D 3CDB D3F8 3652 FBD8  02D5 3B6C 5F1D 2C7B 6B02
https://sks-keyservers.net/pks/lookup?op=get&search=0x3B6C5F1D2C7B6B02
Dominick Grift
#2 lore raw
Quoted 11 lines · Dominick Grift
Quoted 10 lines · Miroslav Vadkerti

For modify action actually audit the selinux type, i.e. use setype variable.

For deleting equal fcontext rules do not audit ftype, as the ftype value for equal rules makes little sense.

policycoreutils/semanage/seobject.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)

Quoted 9 lines
Quoted 6 lines
(quoted diff) +0 -0

b/policycoreutils/semanage/seobject.py index 786ed0e..8d3088c 100644 --- a/policycoreutils/semanage/seobject.py +++ b/policycoreutils/semanage/seobject.py @@ -1992,7 +1992,7 @@ class fcontextRecords(semanageRecords): if not seuser: seuser = "system_u"

system_u is reference policy specific. this is selinux user space not reference policy user space.

Yes, that's pre-existing though (not added by this patch), and unfortunately pervasive throughout seobject.py.

I guess we'll need to decide how to provide this information so that it doesn't have to be hardcoded in seobject.py, e.g. yet another policy configuration file with default values for each security context field?

Quoted 35 lines
Quoted 16 lines

- self.mylog.log_change("resrc=fcontext op=modify %s
ftype=%s tcontext=%s:%s:%s:%s" % (audit.audit_encode_nv_string("tglob", target, 0), ftype_to_audit[ftype], seuser, "object_r", type, serange)) + self.mylog.log_change("resrc=fcontext op=modify %s ftype=%s tcontext=%s:%s:%s:%s" % (audit.audit_encode_nv_string("tglob", target, 0), ftype_to_audit[ftype], seuser, "object_r", setype, serange))

def modify(self, target, setype, ftype, serange, seuser):
self.begin() @@ -2030,7 +2030,7 @@ class fcontextRecords(semanageRecords): self.equiv.pop(target) self.equal_ind = True

Quoted 10 lines

- self.mylog.log_change("resrc=fcontext
op=delete-equal %s ftype=%s" % (audit.audit_encode_nv_string("tglob", target, 0), ftype_to_audit[ftype])) + self.mylog.log_change("resrc=fcontext op=delete-equal %s" % (audit.audit_encode_nv_string("tglob", target, 0)))

return

_______________________________________________ Selinux mailing list [email protected] To unsubscribe, send email to [email protected]. To get help, send an email containing "help" to [email protected].

#3 lore raw
Quoted 22 lines · Stephen Smalley
Quoted 11 lines · Dominick Grift
Quoted 10 lines · Miroslav Vadkerti

For modify action actually audit the selinux type, i.e. use setype variable.

For deleting equal fcontext rules do not audit ftype, as the ftype value for equal rules makes little sense.

policycoreutils/semanage/seobject.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)

Quoted 9 lines
Quoted 6 lines
(quoted diff) +0 -0

b/policycoreutils/semanage/seobject.py index 786ed0e..8d3088c 100644 --- a/policycoreutils/semanage/seobject.py +++ b/policycoreutils/semanage/seobject.py @@ -1992,7 +1992,7 @@ class fcontextRecords(semanageRecords): if not seuser: seuser = "system_u"

system_u is reference policy specific. this is selinux user space not reference policy user space.

Quoted 7 lines

Yes, that's pre-existing though (not added by this patch), and unfortunately pervasive throughout seobject.py.

I guess we'll need to decide how to provide this information so that it doesn't have to be hardcoded in seobject.py, e.g. yet another policy configuration file with default values for each security context field?

I would not mind that if that is the best approach.

Those object_r occurrences raise another question. Should we be "supporting" defaultrole source (RBACSEP) or not (i suppose we should)

Quoted 37 lines
Quoted 36 lines
Quoted 17 lines

- self.mylog.log_change("resrc=fcontext op=modify %s
ftype=%s tcontext=%s:%s:%s:%s" % (audit.audit_encode_nv_string("tglob", target, 0), ftype_to_audit[ftype], seuser, "object_r", type, serange)) + self.mylog.log_change("resrc=fcontext op=modify %s ftype=%s tcontext=%s:%s:%s:%s" % (audit.audit_encode_nv_string("tglob", target, 0), ftype_to_audit[ftype], seuser, "object_r", setype, serange))

def modify(self, target, setype, ftype, serange, seuser):
self.begin() @@ -2030,7 +2030,7 @@ class fcontextRecords(semanageRecords): self.equiv.pop(target) self.equal_ind = True

Quoted 10 lines

- self.mylog.log_change("resrc=fcontext
op=delete-equal %s ftype=%s" % (audit.audit_encode_nv_string("tglob", target, 0), ftype_to_audit[ftype])) + self.mylog.log_change("resrc=fcontext op=delete-equal %s" % (audit.audit_encode_nv_string("tglob", target, 0)))

return

_______________________________________________ Selinux mailing list [email protected] To unsubscribe, send email to [email protected]. To get help, send an email containing "help" to [email protected].

Signature · 3 lines
Key fingerprint = 5F4D 3CDB D3F8 3652 FBD8  02D5 3B6C 5F1D 2C7B 6B02
https://sks-keyservers.net/pks/lookup?op=get&search=0x3B6C5F1D2C7B6B02
Dominick Grift
#4 lore raw
In reply to Stephen Smalley
Quoted 22 lines · Stephen Smalley
Quoted 11 lines · Dominick Grift
Quoted 10 lines · Miroslav Vadkerti

For modify action actually audit the selinux type, i.e. use setype variable.

For deleting equal fcontext rules do not audit ftype, as the ftype value for equal rules makes little sense.

policycoreutils/semanage/seobject.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)

Quoted 9 lines
Quoted 6 lines
(quoted diff) +0 -0

b/policycoreutils/semanage/seobject.py index 786ed0e..8d3088c 100644 --- a/policycoreutils/semanage/seobject.py +++ b/policycoreutils/semanage/seobject.py @@ -1992,7 +1992,7 @@ class fcontextRecords(semanageRecords): if not seuser: seuser = "system_u"

system_u is reference policy specific. this is selinux user space not reference policy user space.

Quoted 8 lines

Yes, that's pre-existing though (not added by this patch), and unfortunately pervasive throughout seobject.py.

I guess we'll need to decide how to provide this information so that it doesn't have to be hardcoded in seobject.py, e.g. yet another policy configuration file with default values for each security context field?

​The same issue might apply for serange, which also can be an empty string and thus gets audited badly if not some default value.

Quoted 44 lines
Quoted 31 lines
Quoted 17 lines

- self.mylog.log_change("resrc=fcontext op=modify %s
ftype=%s tcontext=%s:%s:%s:%s" % (audit.audit_encode_nv_string("tglob", target, 0), ftype_to_audit[ftype], seuser, "object_r", type, serange)) + self.mylog.log_change("resrc=fcontext op=modify %s ftype=%s tcontext=%s:%s:%s:%s" % (audit.audit_encode_nv_string("tglob", target, 0), ftype_to_audit[ftype], seuser, "object_r", setype, serange))

def modify(self, target, setype, ftype, serange, seuser):
self.begin() @@ -2030,7 +2030,7 @@ class fcontextRecords(semanageRecords): self.equiv.pop(target) self.equal_ind = True

Quoted 10 lines

- self.mylog.log_change("resrc=fcontext
op=delete-equal %s ftype=%s" % (audit.audit_encode_nv_string("tglob", target, 0), ftype_to_audit[ftype])) + self.mylog.log_change("resrc=fcontext op=delete-equal %s" % (audit.audit_encode_nv_string("tglob", target, 0)))

return

Quoted 5 lines

_______________________________________________ Selinux mailing list [email protected] To unsubscribe, send email to [email protected]. To get help, send an email containing "help" to [email protected].

_______________________________________________
Selinux mailing list
[email protected]
To unsubscribe, send email to [email protected]. To get help, send an email containing "help" to [email protected].

Signature · 4 lines
Miroslav Vadkerti :: Senior QE / RHCSS :: BaseOS QE Security
IRC mvadkert #qe #urt #brno #rpmdiff :: GPG 0x25881087
Desk Phone +420 532 294 129 :: Mobile +420 773 944 252
Red Hat Czech s.r.o, Purkyňova 99/71, 612 00, Brno, CR
#5 lore raw

Anyway, could we have this patch applied and sort out a better way of supplying defaults later please?

Thanks,
/M

Quoted 93 lines · Miroslav Vadkerti
Quoted 22 lines · Stephen Smalley
Quoted 11 lines · Dominick Grift
Quoted 10 lines · Miroslav Vadkerti

For modify action actually audit the selinux type, i.e. use setype variable.

For deleting equal fcontext rules do not audit ftype, as the ftype value for equal rules makes little sense.

policycoreutils/semanage/seobject.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)

Quoted 9 lines
Quoted 6 lines
(quoted diff) +0 -0

b/policycoreutils/semanage/seobject.py index 786ed0e..8d3088c 100644 --- a/policycoreutils/semanage/seobject.py +++ b/policycoreutils/semanage/seobject.py @@ -1992,7 +1992,7 @@ class fcontextRecords(semanageRecords): if not seuser: seuser = "system_u"

system_u is reference policy specific. this is selinux user space not reference policy user space.

Quoted 8 lines

Yes, that's pre-existing though (not added by this patch), and unfortunately pervasive throughout seobject.py.

I guess we'll need to decide how to provide this information so that it doesn't have to be hardcoded in seobject.py, e.g. yet another policy configuration file with default values for each security context field?

​The same issue might apply for serange, which also can be an empty string and thus gets audited badly if not some default value.

Quoted 37 lines
Quoted 31 lines
Quoted 17 lines

- self.mylog.log_change("resrc=fcontext op=modify %s
ftype=%s tcontext=%s:%s:%s:%s" % (audit.audit_encode_nv_string("tglob", target, 0), ftype_to_audit[ftype], seuser, "object_r", type, serange)) + self.mylog.log_change("resrc=fcontext op=modify %s ftype=%s tcontext=%s:%s:%s:%s" % (audit.audit_encode_nv_string("tglob", target, 0), ftype_to_audit[ftype], seuser, "object_r", setype, serange))

def modify(self, target, setype, ftype, serange, seuser):
self.begin() @@ -2030,7 +2030,7 @@ class fcontextRecords(semanageRecords): self.equiv.pop(target) self.equal_ind = True

Quoted 10 lines

- self.mylog.log_change("resrc=fcontext
op=delete-equal %s ftype=%s" % (audit.audit_encode_nv_string("tglob", target, 0), ftype_to_audit[ftype])) + self.mylog.log_change("resrc=fcontext op=delete-equal %s" % (audit.audit_encode_nv_string("tglob", target, 0)))

return

Quoted 5 lines

_______________________________________________ Selinux mailing list [email protected] To unsubscribe, send email to [email protected]. To get help, send an email containing "help" to [email protected].

Quoted 7 lines

_______________________________________________
Selinux mailing list
[email protected]
To unsubscribe, send email to [email protected]. To get help, send an email containing "help" to [email protected].

--
Miroslav Vadkerti :: Senior QE / RHCSS :: BaseOS QE Security IRC mvadkert #qe #urt #brno #rpmdiff :: GPG 0x25881087 Desk Phone +420 532 294 129 :: Mobile +420 773 944 252 Red Hat Czech s.r.o, Purkyňova 99/71, 612 00, Brno, CR

Signature · 4 lines
Miroslav Vadkerti :: Senior QE / RHCSS :: BaseOS QE Security
IRC mvadkert #qe #urt #brno #rpmdiff :: GPG 0x25881087
Desk Phone +420 532 294 129 :: Mobile +420 773 944 252
Red Hat Czech s.r.o, Purkyňova 99/71, 612 00, Brno, CR
#6 lore raw
Quoted 3 lines · Miroslav Vadkerti

Anyway, could we have this patch applied and sort out a better way of supplying defaults later please?

I hope you do realize that this also affects your customers by essentially forcing them to use your identifiers. with these MLS identifiers that is not a big deal but with system_u it is a bigger deal because now your customers will have to work around this if they wish to take advantage of CIL and its namespace features by namespacing selinux user identities.

Quoted 101 lines

Thanks,
/M

Quoted 93 lines · Miroslav Vadkerti
Quoted 22 lines · Stephen Smalley
Quoted 11 lines · Dominick Grift
Quoted 10 lines · Miroslav Vadkerti

For modify action actually audit the selinux type, i.e. use setype variable.

For deleting equal fcontext rules do not audit ftype, as the ftype value for equal rules makes little sense.

policycoreutils/semanage/seobject.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)

Quoted 9 lines
Quoted 6 lines
(quoted diff) +0 -0

b/policycoreutils/semanage/seobject.py index 786ed0e..8d3088c 100644 --- a/policycoreutils/semanage/seobject.py +++ b/policycoreutils/semanage/seobject.py @@ -1992,7 +1992,7 @@ class fcontextRecords(semanageRecords): if not seuser: seuser = "system_u"

system_u is reference policy specific. this is selinux user space not reference policy user space.

Quoted 8 lines

Yes, that's pre-existing though (not added by this patch), and unfortunately pervasive throughout seobject.py.

I guess we'll need to decide how to provide this information so that it doesn't have to be hardcoded in seobject.py, e.g. yet another policy configuration file with default values for each security context field?

​The same issue might apply for serange, which also can be an empty string and thus gets audited badly if not some default value.

Quoted 37 lines
Quoted 31 lines
Quoted 17 lines

- self.mylog.log_change("resrc=fcontext op=modify %s
ftype=%s tcontext=%s:%s:%s:%s" % (audit.audit_encode_nv_string("tglob", target, 0), ftype_to_audit[ftype], seuser, "object_r", type, serange)) + self.mylog.log_change("resrc=fcontext op=modify %s ftype=%s tcontext=%s:%s:%s:%s" % (audit.audit_encode_nv_string("tglob", target, 0), ftype_to_audit[ftype], seuser, "object_r", setype, serange))

def modify(self, target, setype, ftype, serange, seuser):
self.begin() @@ -2030,7 +2030,7 @@ class fcontextRecords(semanageRecords): self.equiv.pop(target) self.equal_ind = True

Quoted 10 lines

- self.mylog.log_change("resrc=fcontext
op=delete-equal %s ftype=%s" % (audit.audit_encode_nv_string("tglob", target, 0), ftype_to_audit[ftype])) + self.mylog.log_change("resrc=fcontext op=delete-equal %s" % (audit.audit_encode_nv_string("tglob", target, 0)))

return

Quoted 5 lines

_______________________________________________ Selinux mailing list [email protected] To unsubscribe, send email to [email protected]. To get help, send an email containing "help" to [email protected].

Quoted 7 lines

_______________________________________________
Selinux mailing list
[email protected]
To unsubscribe, send email to [email protected]. To get help, send an email containing "help" to [email protected].

--
Miroslav Vadkerti :: Senior QE / RHCSS :: BaseOS QE Security IRC mvadkert #qe #urt #brno #rpmdiff :: GPG 0x25881087 Desk Phone +420 532 294 129 :: Mobile +420 773 944 252 Red Hat Czech s.r.o, Purkyňova 99/71, 612 00, Brno, CR

Signature · 3 lines
Key fingerprint = 5F4D 3CDB D3F8 3652 FBD8  02D5 3B6C 5F1D 2C7B 6B02
https://sks-keyservers.net/pks/lookup?op=get&search=0x3B6C5F1D2C7B6B02
Dominick Grift
Applied
#7 lore raw
In reply to Miroslav Vadkerti
Quoted 7 lines · Miroslav Vadkerti

For modify action actually audit the selinux type, i.e. use setype variable.

For deleting equal fcontext rules do not audit ftype, as the ftype value for equal rules makes little sense.

Applied.

Thanks,
Jim

Quoted 27 lines
---
 policycoreutils/semanage/seobject.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
policycoreutils/semanage/seobject.py +2 -2
index 786ed0e..8d3088c 100644
@@ -1992,7 +1992,7 @@ class fcontextRecords(semanageRecords):
         if not seuser:
             seuser = "system_u"
 
-        self.mylog.log_change("resrc=fcontext op=modify %s ftype=%s tcontext=%s:%s:%s:%s" % (audit.audit_encode_nv_string("tglob", target, 0), ftype_to_audit[ftype], seuser, "object_r", type, serange))
+        self.mylog.log_change("resrc=fcontext op=modify %s ftype=%s tcontext=%s:%s:%s:%s" % (audit.audit_encode_nv_string("tglob", target, 0), ftype_to_audit[ftype], seuser, "object_r", setype, serange))
 
     def modify(self, target, setype, ftype, serange, seuser):
         self.begin()
@@ -2030,7 +2030,7 @@ class fcontextRecords(semanageRecords):
             self.equiv.pop(target)
             self.equal_ind = True
 
-            self.mylog.log_change("resrc=fcontext op=delete-equal %s ftype=%s" % (audit.audit_encode_nv_string("tglob", target, 0), ftype_to_audit[ftype]))
+            self.mylog.log_change("resrc=fcontext op=delete-equal %s" % (audit.audit_encode_nv_string("tglob", target, 0)))
 
             return
 
Signature · 2 lines
James Carter <[email protected]>
National Security Agency