lkml.org 
[lkml]   [2020]   [Jan]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH ghak25 v2 9/9] netfilter: audit table unregister actions
On Mon, Jan 6, 2020 at 1:56 PM Richard Guy Briggs <rgb@redhat.com> wrote:
>
> 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>
> ---
> kernel/auditsc.c | 3 ++-
> net/bridge/netfilter/ebtables.c | 3 +++
> net/netfilter/x_tables.c | 4 +++-
> 3 files changed, 8 insertions(+), 2 deletions(-)

... and in keeping with an ongoing theme for this patchset, please
squash this patch too.

> 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

--
paul moore
www.paul-moore.com

\
 
 \ /
  Last update: 2020-01-31 04:19    [W:0.202 / U:0.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site