Skip to content

Commit fbabf31

Browse files
Thomas Grafkaber
authored andcommitted
netfilter: create audit records for x_tables replaces
The setsockopt() syscall to replace tables is already recorded in the audit logs. This patch stores additional information such as table name and netfilter protocol. Cc: Patrick McHardy <kaber@trash.net> Cc: Eric Paris <eparis@parisplace.org> Cc: Al Viro <viro@ZenIV.linux.org.uk> Signed-off-by: Thomas Graf <tgraf@redhat.com> Signed-off-by: Patrick McHardy <kaber@trash.net>
1 parent 43f393c commit fbabf31

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

‎include/linux/audit.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
#define AUDIT_CAPSET 1322 /* Record showing argument to sys_capset */
105105
#define AUDIT_MMAP 1323 /* Record showing descriptor and flags in mmap */
106106
#define AUDIT_NETFILTER_PKT 1324 /* Packets traversing netfilter chains */
107+
#define AUDIT_NETFILTER_CFG 1325 /* Netfilter chain modifications */
107108

108109
#define AUDIT_AVC 1400 /* SE Linux avc denial or grant */
109110
#define AUDIT_SELINUX_ERR 1401 /* Internal SE Linux Errors */

‎net/netfilter/x_tables.c‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <linux/mutex.h>
2424
#include <linux/mm.h>
2525
#include <linux/slab.h>
26+
#include <linux/audit.h>
2627
#include <net/net_namespace.h>
2728

2829
#include <linux/netfilter/x_tables.h>
@@ -834,6 +835,21 @@ xt_replace_table(struct xt_table *table,
834835
*/
835836
local_bh_enable();
836837

838+
#ifdef CONFIG_AUDIT
839+
if (audit_enabled) {
840+
struct audit_buffer *ab;
841+
842+
ab = audit_log_start(current->audit_context, GFP_KERNEL,
843+
AUDIT_NETFILTER_CFG);
844+
if (ab) {
845+
audit_log_format(ab, "table=%s family=%u entries=%u",
846+
table->name, table->af,
847+
private->number);
848+
audit_log_end(ab);
849+
}
850+
}
851+
#endif
852+
837853
return private;
838854
}
839855
EXPORT_SYMBOL_GPL(xt_replace_table);

0 commit comments

Comments
 (0)