netfilter: add audit table unregister actions
authorRichard Guy Briggs <rgb@redhat.com>
Wed, 22 Apr 2020 21:39:29 +0000 (17:39 -0400)
committerPaul Moore <paul@paul-moore.com>
Tue, 28 Apr 2020 22:11:36 +0000 (18:11 -0400)
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@redhat.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
include/linux/audit.h
kernel/auditsc.c
net/bridge/netfilter/ebtables.c
net/netfilter/x_tables.c

index 5c7f07a9776d255f209916b95a67fa6b765ae037..1a23515082113e2b261bd7772fb209e6370fc432 100644 (file)
@@ -97,6 +97,7 @@ struct audit_ntp_data {};
 enum audit_nfcfgop {
        AUDIT_XT_OP_REGISTER,
        AUDIT_XT_OP_REPLACE,
+       AUDIT_XT_OP_UNREGISTER,
 };
 
 extern int is_audit_feature_set(int which);
index 705beac0ce29b9fc1a9601339d660f0b9dee24be..d281c18d1771a6708a89ec3787d79149832f1137 100644 (file)
@@ -136,8 +136,9 @@ struct audit_nfcfgop_tab {
 };
 
 const struct audit_nfcfgop_tab audit_nfcfgs[] = {
-       { AUDIT_XT_OP_REGISTER, "register"      },
-       { AUDIT_XT_OP_REPLACE,  "replace"       },
+       { AUDIT_XT_OP_REGISTER,         "register"      },
+       { AUDIT_XT_OP_REPLACE,          "replace"       },
+       { AUDIT_XT_OP_UNREGISTER,       "unregister"    },
 };
 
 static int audit_match_perm(struct audit_context *ctx, int mask)
index 0a148e68b6e150e87bd4bcbcb3941fcacf5dceb9..4778db5601b0d082a2d932e0cd6548964cf69a81 100644 (file)
@@ -1124,6 +1124,8 @@ static void __ebt_unregister_table(struct net *net, struct ebt_table *table)
        mutex_lock(&ebt_mutex);
        list_del(&table->list);
        mutex_unlock(&ebt_mutex);
+       audit_log_nfcfg(table->name, AF_BRIDGE, table->private->nentries,
+                       AUDIT_XT_OP_UNREGISTER);
        EBT_ENTRY_ITERATE(table->private->entries, table->private->entries_size,
                          ebt_cleanup_entry, net, NULL);
        if (table->private->nentries)
index 8f8c5dbf603df2c5f73e8bb0e894031191fbd7ea..99a468be4a59fb1995c91d8400b0cc2bf987623a 100644 (file)
@@ -1472,6 +1472,8 @@ void *xt_unregister_table(struct xt_table *table)
        private = table->private;
        list_del(&table->list);
        mutex_unlock(&xt[table->af].mutex);
+       audit_log_nfcfg(table->name, table->af, private->number,
+                       AUDIT_XT_OP_UNREGISTER);
        kfree(table);
 
        return private;