netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Add SELinux context support to AUDIT target
@ 2011-05-20  1:09 Mr Dash Four
  2011-05-26 16:49 ` Pablo Neira Ayuso
  0 siblings, 1 reply; 45+ messages in thread
From: Mr Dash Four @ 2011-05-20  1:09 UTC (permalink / raw)
  To: netfilter-devel

Add SELinux context support for AUDIT target. Typical (raw auditd) output after applying this patch would be:

type=NETFILTER_PKT msg=audit(1305852240.082:31012): action=0 hook=3 len=52 inif=? outif=eth0 subj=system_u:object_r:sshd_packet_t:s0 saddr=10.1.1.7 daddr=10.1.2.1 ipid=16312 proto=6 sport=56150 dport=22


Signed-off-by: Mr Dash Four <mr.dash.four@googlemail.com>
---
 net/netfilter/xt_AUDIT.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/net/netfilter/xt_AUDIT.c b/net/netfilter/xt_AUDIT.c
index 363a99e..438f82a 100644
--- a/net/netfilter/xt_AUDIT.c
+++ b/net/netfilter/xt_AUDIT.c
@@ -20,6 +20,7 @@
 #include <linux/netfilter/x_tables.h>
 #include <linux/netfilter/xt_AUDIT.h>
 #include <linux/netfilter_bridge/ebtables.h>
+#include <linux/security.h>
 #include <net/ipv6.h>
 #include <net/ip.h>
 
@@ -122,6 +123,10 @@ audit_tg(struct sk_buff *skb, const struct xt_action_param *par)
 {
 	const struct xt_audit_info *info = par->targinfo;
 	struct audit_buffer *ab;
+#ifdef CONFIG_NF_CONNTRACK_SECMARK
+	u32 len;
+	char *secctx;
+#endif
 
 	ab = audit_log_start(NULL, GFP_ATOMIC, AUDIT_NETFILTER_PKT);
 	if (ab == NULL)
@@ -135,6 +140,14 @@ audit_tg(struct sk_buff *skb, const struct xt_action_param *par)
 	if (skb->mark)
 		audit_log_format(ab, " mark=%#x", skb->mark);
 
+#ifdef CONFIG_NF_CONNTRACK_SECMARK
+	if (skb->secmark)
+	  	if (!security_secid_to_secctx(skb->secmark, &secctx, &len)) {
+			audit_log_format(ab, " subj=%s", secctx);
+			security_release_secctx(secctx, len);
+		}
+#endif
+
 	if (skb->dev && skb->dev->type == ARPHRD_ETHER) {
 		audit_log_format(ab, " smac=%pM dmac=%pM macproto=0x%04x",
 				 eth_hdr(skb)->h_source, eth_hdr(skb)->h_dest,
-- 
1.7.3.4




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

end of thread, other threads:[~2011-06-30 11:35 UTC | newest]

Thread overview: 45+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-20  1:09 [PATCH] Add SELinux context support to AUDIT target Mr Dash Four
2011-05-26 16:49 ` Pablo Neira Ayuso
2011-05-26 17:03   ` Mr Dash Four
2011-05-26 17:44     ` Pablo Neira Ayuso
2011-06-04 15:12     ` [PATCH 2nd revision] " Mr Dash Four
2011-06-05 23:06       ` Pablo Neira Ayuso
2011-06-06 12:02         ` Mr Dash Four
2011-06-06 23:20           ` Pablo Neira Ayuso
2011-06-07  8:18             ` Mr Dash Four
2011-06-07  9:12               ` Pablo Neira Ayuso
2011-06-07 10:32                 ` [PATCH 3rd " Mr Dash Four
2011-06-08 14:49                   ` Steve Grubb
2011-06-08 16:12                     ` Mr Dash Four
2011-06-08 17:14                       ` Steve Grubb
2011-06-08 18:04                         ` Mr Dash Four
2011-06-08 18:13                     ` Casey Schaufler
2011-06-08 18:33                       ` Eric Paris
2011-06-08 19:00                         ` Mr Dash Four
2011-06-08 19:08                           ` Eric Paris
2011-06-08 19:14                             ` Mr Dash Four
2011-06-08 19:28                             ` Steve Grubb
2011-06-08 19:39                               ` Eric Paris
2011-06-09 12:28                                 ` Patrick McHardy
2011-06-09 12:52                                   ` Eric Paris
2011-06-09 12:56                                     ` Patrick McHardy
2011-06-09 14:08                                     ` Mr Dash Four
2011-06-09 15:06                                       ` Eric Paris
2011-06-09 15:16                                         ` Mr Dash Four
2011-06-16  8:36                                           ` Mr Dash Four
2011-06-18 12:08                                             ` [PATCH 4th " Mr Dash Four
2011-06-20 12:20                                               ` Steve Grubb
2011-06-20 14:21                                                 ` Mr Dash Four
2011-06-20 14:27                                                   ` Eric Paris
2011-06-30 11:35                                                     ` Patrick McHardy
2011-06-08 18:36                       ` [PATCH 3rd " Steve Grubb
2011-06-08 18:45                         ` Mr Dash Four
2011-06-06 12:14       ` [PATCH 2nd " Steve Grubb
2011-06-06 12:25         ` Mr Dash Four
2011-06-06 12:30           ` Steve Grubb
2011-06-06 12:42             ` Mr Dash Four
2011-06-06 12:53               ` Steve Grubb
2011-06-06 13:10                 ` Mr Dash Four
2011-06-06 23:22                   ` Pablo Neira Ayuso
2011-06-07  0:59                     ` Steve Grubb
2011-06-07  1:23                       ` Casey Schaufler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).