Skip to contentSkip to conversation

Don't send statistics to audit logs

PATCH Steve G 2 participants 3 messages Aug 18, 2006 – Aug 23, 2006 SELinux security module

lore
Share & tools
lore

Steve G

author
#0 lore raw

Hi,

The attached patch changes libselinux to send statistics to syslog instead of the audit logs.

Thanks,
-Steve

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

src/avc.c +3 -2
diff -ur libselinux-1.30.20.orig/src/avc.c libselinux-1.30.20/src/avc.c
@@ -15,6 +15,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <stdint.h>
+#include <syslog.h>
 #include <selinux/flask.h>
 #include "selinux_internal.h"
 #include <selinux/avc.h>
@@ -331,7 +332,7 @@
 	avc_get_lock(avc_lock);
 	sidtab_sid_stats(&avc_sidtab, avc_audit_buf, AVC_AUDIT_BUFSIZE);
 	avc_release_lock(avc_lock);
-	avc_log("%s", avc_audit_buf);
+	syslog(LOG_INFO, "%s", avc_audit_buf);
 	avc_release_lock(avc_log_lock);
 }
 
@@ -360,7 +361,7 @@
 
 	avc_release_lock(avc_lock);
 
-	avc_log("%s:  %d AV entries and %d/%d buckets used, "
+	syslog(LOG_INFO, "%s:  %d AV entries and %d/%d buckets used, "
 		"longest chain length %d\n", avc_prefix,
 		avc_cache.active_nodes,
 		slots_used, AVC_CACHE_SLOTS, max_chain_len);
#1 lore raw
Quoted 4 lines · Steve G

Hi,

The attached patch changes libselinux to send statistics to syslog instead of the audit logs.

I don't think we want this particular patch, but we can still meet the spirit of what you want. As is, the patch makes the output unconditionally go to syslog, whereas at present, the caller is free to suppress or redirect the output via his own callback function. I think you just want to stop having avc_ss_reset automatically invoke avc_av_stats(), so that that output (which is essentially debug/development information) is not included upon policy reloads and enforcing status changes. The application is still free to explicitly call avc_av_stats() or avc_sid_stats(), and can set the logging callback as desired a priori or perform filtering within the logging callback.

So I think the patch below would likely suffice for your need.

Index: libselinux/src/avc.c
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libselinux/src/avc.c,v retrieving revision 1.33

src/avc.c +0 -2
diff -u -p -r1.33 avc.c
@@ -1191,8 +1191,6 @@ int avc_ss_reset(u_int32_t seqno)
 {
 	int rc;
 
-	avc_av_stats();
-
 	rc = avc_reset();
 
 	avc_get_lock(avc_lock);
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.
author
#2 lore raw
Quoted 2 lines

So I think the patch below would likely suffice for your need.

OK, sounds good.

On a separate note...I found that with avc_log, there was no good way to specify the audit message type. They are all AUDIT_USER_AVC. Suppose some should be AUDIT_USER_SELINUX_ERR? (There are some messages that are error conditions and not an access vector calculation.)

Thanks,
-Steve

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

--
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.