Skip to contentSkip to conversation

Suppress rule generation for dontaudit rules

PATCH Applied Karl MacMillan 3 participants 7 messages Aug 15, 2007 – Sep 3, 2007 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Suppress rule generation for dontaudit rules

The current policy generation code incorrectly generates allow rules for dontaudit messages. This patch fixes that.

---

sepolgen/src/sepolgen/policygen.py +2 -0
diff -r 56dbe9166d98 -r 2ad2d21fc724 sepolgen/src/sepolgen/policygen.py
@@ -139,6 +139,8 @@ class PolicyGenerator:
 
     def __add_allow_rules(self, avs):
         for av in avs:
+            if not av.denial:
+                continue
             rule = refpolicy.AVRule(av)
             if self.explain:
                 rule.comment = refpolicy.Comment(explain_access(av, verbosity=self.explain))

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Karl MacMillan

The current policy generation code incorrectly generates allow rules for dontaudit messages. This patch fixes that.

---

diff -r 56dbe9166d98 -r 2ad2d21fc724 sepolgen/src/sepolgen/policygen.py

sepolgen/src/sepolgen/policygen.py class PolicyGenerator: · line 146

Quoted 8 lines
sepolgen/src/sepolgen/policygen.py +2 -0
@@ -139,6 +139,8 @@ class PolicyGenerator:
 
     def __add_allow_rules(self, avs):
         for av in avs:
+            if not av.denial:
+                continue
             rule = refpolicy.AVRule(av)
             if self.explain:
                 rule.comment = refpolicy.Comment(explain_access(av, verbosity=self.explain))
Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#2 lore raw
Quoted 12 lines · Stephen Smalley
Quoted 10 lines · Karl MacMillan

The current policy generation code incorrectly generates allow rules for dontaudit messages. This patch fixes that.

---

diff -r 56dbe9166d98 -r 2ad2d21fc724 sepolgen/src/sepolgen/policygen.py

sepolgen/src/sepolgen/policygen.py +0 -0
@@ -139,6 +139,8 @@ class PolicyGenerator:
 
Quoted 12 lines

sepolgen/src/sepolgen/policygen.py class PolicyGenerator: · line 146

Quoted 9 lines
sepolgen/src/sepolgen/policygen.py +2 -0
     def __add_allow_rules(self, avs):
         for av in avs:
+            if not av.denial:
+                continue
             rule = refpolicy.AVRule(av)
             if self.explain:
                 rule.comment = refpolicy.Comment(explain_access(av, verbosity=self.explain))

Merged into 1.0.9

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#3 lore raw
Quoted 26 lines · Joshua Brindle
Quoted 12 lines · Stephen Smalley
Quoted 10 lines · Karl MacMillan

The current policy generation code incorrectly generates allow rules for dontaudit messages. This patch fixes that.

---

diff -r 56dbe9166d98 -r 2ad2d21fc724 sepolgen/src/sepolgen/policygen.py

sepolgen/src/sepolgen/policygen.py +0 -0
@@ -139,6 +139,8 @@ class PolicyGenerator:
 
Quoted 12 lines

sepolgen/src/sepolgen/policygen.py class PolicyGenerator: · line 146

Quoted 9 lines
sepolgen/src/sepolgen/policygen.py +2 -0
     def __add_allow_rules(self, avs):
         for av in avs:
+            if not av.denial:
+                continue
             rule = refpolicy.AVRule(av)
             if self.explain:
                 rule.comment = refpolicy.Comment(explain_access(av, verbosity=self.explain))
Quoted 1 line

Merged into 1.0.9

Reverted. Didn't work.

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#4 lore raw
Quoted 6 lines · Stephen Smalley
Quoted 5 lines · Joshua Brindle
Quoted 4 lines · Stephen Smalley
Quoted 2 lines · Karl MacMillan

The current policy generation code incorrectly generates allow rules for dontaudit messages. This patch fixes that.

[...]

Quoted 5 lines
Quoted 2 lines

Merged into 1.0.9

Reverted. Didn't work.

That's because it was wildly wrong - I thought I tested that, but I guess not. Correct patch below:

sepolgen/src/sepolgen/audit.py +2 -0
diff -r e962f4f773fc sepolgen/src/sepolgen/audit.py
@@ -421,6 +421,8 @@ class AuditParser:
         """
         av_set = access.AccessVectorSet()
         for avc in self.avc_msgs:
+            if avc.denial == True:
+                continue
             if avc_filter:
                 if avc_filter.filter(avc):
                     av_set.add(avc.scontext.type, avc.tcontext.type, avc.tclass,

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#5 lore raw
Quoted 31 lines · Karl MacMillan
Quoted 6 lines · Stephen Smalley
Quoted 5 lines · Joshua Brindle
Quoted 4 lines · Stephen Smalley
Quoted 2 lines · Karl MacMillan

The current policy generation code incorrectly generates allow rules for dontaudit messages. This patch fixes that.

[...]

Quoted 5 lines
Quoted 2 lines

Merged into 1.0.9

Reverted. Didn't work.

That's because it was wildly wrong - I thought I tested that, but I guess not. Correct patch below:

diff -r e962f4f773fc sepolgen/src/sepolgen/audit.py

sepolgen/src/sepolgen/audit.py +2 -0
@@ -421,6 +421,8 @@ class AuditParser:
         """
         av_set = access.AccessVectorSet()
         for avc in self.avc_msgs:
+            if avc.denial == True:
+                continue
             if avc_filter:
                 if avc_filter.filter(avc):
                     av_set.add(avc.scontext.type, avc.tcontext.type, avc.tclass,
Quoted 1 line

Causes all avc messages to be discarded, yielding no output from audit2allow -a (with a number of avc messages in audit.log). NAK. Third time's the charm?

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#6 lore raw
Quoted 32 lines · Stephen Smalley
Quoted 31 lines · Karl MacMillan
Quoted 6 lines · Stephen Smalley
Quoted 5 lines · Joshua Brindle
Quoted 4 lines · Stephen Smalley
Quoted 2 lines · Karl MacMillan

The current policy generation code incorrectly generates allow rules for dontaudit messages. This patch fixes that.

[...]

Quoted 5 lines
Quoted 2 lines

Merged into 1.0.9

Reverted. Didn't work.

That's because it was wildly wrong - I thought I tested that, but I guess not. Correct patch below:

diff -r e962f4f773fc sepolgen/src/sepolgen/audit.py

sepolgen/src/sepolgen/audit.py +2 -0
@@ -421,6 +421,8 @@ class AuditParser:
         """
         av_set = access.AccessVectorSet()
         for avc in self.avc_msgs:
+            if avc.denial == True:
+                continue
             if avc_filter:
                 if avc_filter.filter(avc):
                     av_set.add(avc.scontext.type, avc.tcontext.type, avc.tclass,
Quoted 6 lines
Quoted 1 line

Causes all avc messages to be discarded, yielding no output from audit2allow -a (with a number of avc messages in audit.log). NAK. Third time's the charm?

We can hope - this version includes a test. If this isn't right someone else will have to fix this bug.

Suppress rule generation for dontaudit rules.

The current policy generation code incorrectly generates allow rules for dontaudit messages. This patch fixes that.

sepolgen/src/sepolgen/audit.py +3 -1
diff -r e962f4f773fc sepolgen/src/sepolgen/audit.py
@@ -402,7 +402,7 @@ class AuditParser:
             self.__parse(l)
         self.__post_process()
 
-    def to_access(self, avc_filter=None):
+    def to_access(self, avc_filter=None, only_denials=True):
         """Convert the audit logs access into a an access vector set.
 
         Convert the audit logs into an access vector set, optionally
@@ -421,6 +421,8 @@ class AuditParser:
         """
         av_set = access.AccessVectorSet()
         for avc in self.avc_msgs:
+            if avc.denial != True and only_denials:
+                continue
             if avc_filter:
                 if avc_filter.filter(avc):
                     av_set.add(avc.scontext.type, avc.tcontext.type, avc.tclass,
sepolgen/tests/test_audit.py +41 -0

57 lines not on this page · raw message

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.