Skip to contentSkip to conversation

netfilter: create audit records for ebtables replaces

PATCH In review Nicolas Dichtel 3 participants 5 messages Sep 5, 2014 – Sep 9, 2014

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 netfilter: create audit records for ebtables replaces

This is already done for x_tables (family AF_INET and AF_INET6), let's do it for AF_BRIDGE also.

---
 net/bridge/netfilter/ebtables.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
net/bridge/netfilter/ebtables.c +15 -0
index 6d69631b9f4d..4ba0c5c78778 100644
@@ -26,6 +26,7 @@
 #include <asm/uaccess.h>
 #include <linux/smp.h>
 #include <linux/cpumask.h>
+#include <linux/audit.h>
 #include <net/sock.h>
 /* needed for logical [in,out]-dev filtering */
 #include "../br_private.h"
@@ -1126,6 +1127,20 @@ static int do_replace(struct net *net, const void __user *user,
 	}
 
 	ret = do_replace_finish(net, &tmp, newinfo);
+#ifdef CONFIG_AUDIT
+	if (audit_enabled) {
+		struct audit_buffer *ab;
+
+		ab = audit_log_start(current->audit_context, GFP_KERNEL,
+				     AUDIT_NETFILTER_CFG);
+		if (ab) {
+			audit_log_format(ab, "table=%s family=%u entries=%u",
+					 tmp.name, AF_BRIDGE,
+					 tmp.nentries);
+			audit_log_end(ab);
+		}
+	}
+#endif
 	if (ret == 0)
 		return ret;
 free_entries:
Signature · 1 line
1.9.0
#1 lore raw
Quoted 28 lines · Nicolas Dichtel

This is already done for x_tables (family AF_INET and AF_INET6), let's do it for AF_BRIDGE also.

---
 net/bridge/netfilter/ebtables.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
net/bridge/netfilter/ebtables.c +5 -0
index 6d69631b9f4d..4ba0c5c78778 100644
@@ -26,6 +26,7 @@
 #include <asm/uaccess.h>
 #include <linux/smp.h>
 #include <linux/cpumask.h>
+#include <linux/audit.h>
 #include <net/sock.h>
 /* needed for logical [in,out]-dev filtering */
 #include "../br_private.h"
@@ -1126,6 +1127,20 @@ static int do_replace(struct net *net, const void __user *user,
 	}
 
 	ret = do_replace_finish(net, &tmp, newinfo);
+#ifdef CONFIG_AUDIT
+	if (audit_enabled) {
+		struct audit_buffer *ab;
+

net/bridge/netfilter/ebtables.c static int do_replace(struct net *net, const void __user *user, · line 1143

Quoted 10 lines
net/bridge/netfilter/ebtables.c +10 -0
+		ab = audit_log_start(current->audit_context, GFP_KERNEL,
+				     AUDIT_NETFILTER_CFG);
+		if (ab) {
+			audit_log_format(ab, "table=%s family=%u entries=%u",
+					 tmp.name, AF_BRIDGE,
+					 tmp.nentries);
+			audit_log_end(ab);
+		}
+	}
+#endif

This chunks belongs to do_replace_finish(). We still need the audit code for compat_do_replace() and iff there are no errors when replacing the table.

Quoted 6 lines
net/bridge/netfilter/ebtables.c +0 -0
 	if (ret == 0)
 		return ret;
 free_entries:
Signature · 1 line
1.9.0
#2 lore raw

PATCH 1/1 netfilter: create audit records for ebtables replaces

This is already done for x_tables (family AF_INET and AF_INET6), let's do it for AF_BRIDGE also.

---

v2: move audit chunks to do_replace_finish()

 net/bridge/netfilter/ebtables.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
net/bridge/netfilter/ebtables.c +15 -0
index 6d69631b9f4d..d9a8c05d995d 100644
@@ -26,6 +26,7 @@
 #include <asm/uaccess.h>
 #include <linux/smp.h>
 #include <linux/cpumask.h>
+#include <linux/audit.h>
 #include <net/sock.h>
 /* needed for logical [in,out]-dev filtering */
 #include "../br_private.h"
@@ -1058,6 +1059,20 @@ static int do_replace_finish(struct net *net, struct ebt_replace *repl,
 	vfree(table);
 
 	vfree(counterstmp);
+
+#ifdef CONFIG_AUDIT
+	if (audit_enabled) {
+		struct audit_buffer *ab;
+
+		ab = audit_log_start(current->audit_context, GFP_KERNEL,
+				     AUDIT_NETFILTER_CFG);
+		if (ab) {
+			audit_log_format(ab, "table=%s family=%u entries=%u",
+					 repl->name, AF_BRIDGE, repl->nentries);
+			audit_log_end(ab);
+		}
+	}
+#endif
 	return ret;
 
 free_unlock:
Signature · 1 line
1.9.0
maintainer Applied
#3 lore raw
Quoted 2 lines · Nicolas Dichtel

This is already done for x_tables (family AF_INET and AF_INET6), let's do it for AF_BRIDGE also.

Applied, thanks Nicolas.

#4 lore raw
In reply to Nicolas Dichtel
Quoted 4 lines · Nicolas Dichtel

This is already done for x_tables (family AF_INET and AF_INET6), let's do it for AF_BRIDGE also.

ACK.

Quoted 44 lines
---
 net/bridge/netfilter/ebtables.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
net/bridge/netfilter/ebtables.c +15 -0
index 6d69631b9f4d..4ba0c5c78778 100644
@@ -26,6 +26,7 @@
 #include <asm/uaccess.h>
 #include <linux/smp.h>
 #include <linux/cpumask.h>
+#include <linux/audit.h>
 #include <net/sock.h>
 /* needed for logical [in,out]-dev filtering */
 #include "../br_private.h"
@@ -1126,6 +1127,20 @@ static int do_replace(struct net *net, const void __user *user,
 	}
 
 	ret = do_replace_finish(net, &tmp, newinfo);
+#ifdef CONFIG_AUDIT
+	if (audit_enabled) {
+		struct audit_buffer *ab;
+
+		ab = audit_log_start(current->audit_context, GFP_KERNEL,
+				     AUDIT_NETFILTER_CFG);
+		if (ab) {
+			audit_log_format(ab, "table=%s family=%u entries=%u",
+					 tmp.name, AF_BRIDGE,
+					 tmp.nentries);
+			audit_log_end(ab);
+		}
+	}
+#endif
 	if (ret == 0)
 		return ret;
 free_entries:
Signature · 6 lines
1.9.0

--
Linux-audit mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/linux-audit

- RGB

--
Richard Guy Briggs <[email protected]>
Senior Software Engineer, Kernel Security, AMER ENG Base Operating Systems, Red Hat Remote, Ottawa, Canada
Voice: +1.647.777.2635, Internal: (81) 32635, Alt: +1.613.693.0684x3545