Audit the action of unregistering ebtables and x_tables. See: https://github.com/linux-audit/audit-kernel/issues/44 Signed-off-by: Richard Guy Briggs <rgb@xxxxxxxxxx> --- kernel/auditsc.c | 3 ++- net/bridge/netfilter/ebtables.c | 3 +++ net/netfilter/x_tables.c | 4 +++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/kernel/auditsc.c b/kernel/auditsc.c index 999ac184246b..2644130a9e66 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c @@ -2557,7 +2557,8 @@ void __audit_nf_cfg(const char *name, u8 af, int nentries, int op) return; /* audit_panic or being filtered */ audit_log_format(ab, "table=%s family=%u entries=%u op=%s", name, af, nentries, - op ? "replace" : "register"); + op == 1 ? "replace" : + (op ? "unregister" : "register")); audit_log_end(ab); } EXPORT_SYMBOL_GPL(__audit_nf_cfg); diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c index baff2f05af43..3dd4eb5b13fd 100644 --- a/net/bridge/netfilter/ebtables.c +++ b/net/bridge/netfilter/ebtables.c @@ -1126,6 +1126,9 @@ static void __ebt_unregister_table(struct net *net, struct ebt_table *table) mutex_lock(&ebt_mutex); list_del(&table->list); mutex_unlock(&ebt_mutex); + if (audit_enabled) + audit_nf_cfg(table->name, AF_BRIDGE, table->private->nentries, + 2); EBT_ENTRY_ITERATE(table->private->entries, table->private->entries_size, ebt_cleanup_entry, net, NULL); if (table->private->nentries) diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c index 4ae4f7bf8946..e4852a0cb62f 100644 --- a/net/netfilter/x_tables.c +++ b/net/netfilter/x_tables.c @@ -1403,7 +1403,7 @@ struct xt_table_info *xt_replace_table(struct xt_table *table, if (audit_enabled) audit_nf_cfg(table->name, table->af, private->number, - private->number); + !!private->number); return private; } @@ -1466,6 +1466,8 @@ void *xt_unregister_table(struct xt_table *table) private = table->private; list_del(&table->list); mutex_unlock(&xt[table->af].mutex); + if (audit_enabled) + audit_nf_cfg(table->name, table->af, private->number, 2); kfree(table); return private; -- 1.8.3.1