All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] audit validatetrans denials
@ 2005-02-16 21:54 Darrel Goeddel
  2005-02-16 23:54 ` James Morris
  2005-02-17 13:32 ` Stephen Smalley
  0 siblings, 2 replies; 7+ messages in thread
From: Darrel Goeddel @ 2005-02-16 21:54 UTC (permalink / raw)
  To: 'SELinux List'; +Cc: Chad Hanson

[-- Attachment #1: Type: text/plain, Size: 138 bytes --]

Attached is a patch that adds the auditing of denials caused by the 
validatetrans rules in the policy.  Look good?

Thanks,

-- 

Darrel

[-- Attachment #2: validtrans_audit.patch --]
[-- Type: text/x-patch, Size: 1743 bytes --]

diff -ruNp linux-2.6-nsa-20050215/security/selinux/ss/services.c linux-2.6-20050216/security/selinux/ss/services.c
--- linux-2.6-nsa-20050215/security/selinux/ss/services.c	2005-01-27 16:48:31.000000000 -0600
+++ linux-2.6-20050216/security/selinux/ss/services.c	2005-02-16 09:36:40.612223188 -0600
@@ -38,6 +38,13 @@
 #include "services.h"
 #include "conditional.h"
 #include "mls.h"
+#ifdef CONFIG_AUDIT
+static const char *class_to_string[] = {
+#define S_(s) s,
+#include "class_to_string.h"
+#undef S_
+};
+#endif
 
 extern void selnl_notify_policyload(u32 seqno);
 unsigned int policydb_loaded_version;
@@ -417,6 +424,43 @@ int security_validate_transition(u32 old
 
 out:
 	POLICY_RDUNLOCK;
+
+	/* audit failures */
+	if (rc) {
+		int err;
+		char *context;
+		u32 context_len;
+		struct audit_buffer *ab;
+
+		ab = audit_log_start(current->audit_context);
+		if (!ab)
+			return rc; /* audit_panic has been called */
+		audit_log_format(ab, "avc:  denied validate_transition");
+ 		err = security_sid_to_context(oldsid, &context, &context_len);
+		if (err)
+			audit_log_format(ab, " oldsid=%d", oldsid);
+		else {
+			audit_log_format(ab, " oldcontext=%s", context);
+			kfree(context);
+		}
+		err = security_sid_to_context(newsid, &context, &context_len);
+		if (err)
+			audit_log_format(ab, " newsid=%d", newsid);
+		else {
+			audit_log_format(ab, " newcontext=%s", context);
+			kfree(context);
+		}
+		err = security_sid_to_context(tasksid, &context, &context_len);
+		if (err)
+			audit_log_format(ab, " tasksid=%d", tasksid);
+		else {
+			audit_log_format(ab, " taskcontext=%s", context);
+			kfree(context);
+		}
+		audit_log_format(ab, " tclass=%s", class_to_string[tclass]);
+		audit_log_end(ab);
+	}
+
 	return rc;
 }
 

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2005-02-17 19:29 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-02-16 21:54 [PATCH] audit validatetrans denials Darrel Goeddel
2005-02-16 23:54 ` James Morris
2005-02-17 13:32 ` Stephen Smalley
2005-02-17 16:29   ` Darrel Goeddel
2005-02-17 16:29     ` Stephen Smalley
2005-02-17 17:10     ` Stephen Smalley
2005-02-17 19:29       ` Darrel Goeddel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.