* [PATCH v5] audit: log nftables configuration change events once per table
@ 2021-03-26 17:38 ` Richard Guy Briggs
0 siblings, 0 replies; 22+ messages in thread
From: Richard Guy Briggs @ 2021-03-26 17:38 UTC (permalink / raw)
To: Linux-Audit Mailing List, LKML, netfilter-devel
Cc: Jones Desougi, Richard Guy Briggs, Phil Sutter, Florian Westphal,
twoerner, Eric Paris, tgraf, dan.carpenter
Reduce logging of nftables events to a level similar to iptables.
Restore the table field to list the table, adding the generation.
Indicate the op as the most significant operation in the event.
A couple of sample events:
type=PROCTITLE msg=audit(2021-03-18 09:30:49.801:143) : proctitle=/usr/bin/python3 -s /usr/sbin/firewalld --nofork --nopid
type=SYSCALL msg=audit(2021-03-18 09:30:49.801:143) : arch=x86_64 syscall=sendmsg success=yes exit=172 a0=0x6 a1=0x7ffdcfcbe650 a2=0x0 a3=0x7ffdcfcbd52c items=0 ppid=1 pid=367 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=roo
t sgid=root fsgid=root tty=(none) ses=unset comm=firewalld exe=/usr/bin/python3.9 subj=system_u:system_r:firewalld_t:s0 key=(null)
type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.801:143) : table=firewalld:2 family=ipv6 entries=1 op=nft_register_table pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld
type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.801:143) : table=firewalld:2 family=ipv4 entries=1 op=nft_register_table pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld
type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.801:143) : table=firewalld:2 family=inet entries=1 op=nft_register_table pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld
type=PROCTITLE msg=audit(2021-03-18 09:30:49.839:144) : proctitle=/usr/bin/python3 -s /usr/sbin/firewalld --nofork --nopid
type=SYSCALL msg=audit(2021-03-18 09:30:49.839:144) : arch=x86_64 syscall=sendmsg success=yes exit=22792 a0=0x6 a1=0x7ffdcfcbe650 a2=0x0 a3=0x7ffdcfcbd52c items=0 ppid=1 pid=367 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=r
oot sgid=root fsgid=root tty=(none) ses=unset comm=firewalld exe=/usr/bin/python3.9 subj=system_u:system_r:firewalld_t:s0 key=(null)
type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.839:144) : table=firewalld:3 family=ipv6 entries=30 op=nft_register_chain pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld
type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.839:144) : table=firewalld:3 family=ipv4 entries=30 op=nft_register_chain pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld
type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.839:144) : table=firewalld:3 family=inet entries=165 op=nft_register_chain pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld
The issue was originally documented in
https://github.com/linux-audit/audit-kernel/issues/124
Signed-off-by: Richard Guy Briggs <rgb@redhat.com>
---
Changelog:
v5:
(sorry for all the noise...)
- fix kbuild missing prototype warning in nf_tables_commit_audit_{alloc,collect,log}() <lkp@intel.com>
v4:
- move nf_tables_commit_audit_log() before nf_tables_commit_release() [fw]
- move nft2audit_op[] from audit.h to nf_tables_api.c
v3:
- fix function braces, reduce parameter scope [pna]
- pre-allocate nft_audit_data per table in step 1, bail on ENOMEM [pna]
v2:
- convert NFT ops to array indicies in nft2audit_op[] [ps]
- use linux lists [pna]
- use functions for each of collection and logging of audit data [pna]
---
net/netfilter/nf_tables_api.c | 187 +++++++++++++++++++---------------
1 file changed, 104 insertions(+), 83 deletions(-)
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index c1eb5cdb3033..ef51abe3a6d7 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -66,6 +66,41 @@ static const struct rhashtable_params nft_objname_ht_params = {
.automatic_shrinking = true,
};
+struct nft_audit_data {
+ struct nft_table *table;
+ int entries;
+ int op;
+ struct list_head list;
+};
+
+static const u8 nft2audit_op[NFT_MSG_MAX] = { // enum nf_tables_msg_types
+ [NFT_MSG_NEWTABLE] = AUDIT_NFT_OP_TABLE_REGISTER,
+ [NFT_MSG_GETTABLE] = AUDIT_NFT_OP_INVALID,
+ [NFT_MSG_DELTABLE] = AUDIT_NFT_OP_TABLE_UNREGISTER,
+ [NFT_MSG_NEWCHAIN] = AUDIT_NFT_OP_CHAIN_REGISTER,
+ [NFT_MSG_GETCHAIN] = AUDIT_NFT_OP_INVALID,
+ [NFT_MSG_DELCHAIN] = AUDIT_NFT_OP_CHAIN_UNREGISTER,
+ [NFT_MSG_NEWRULE] = AUDIT_NFT_OP_RULE_REGISTER,
+ [NFT_MSG_GETRULE] = AUDIT_NFT_OP_INVALID,
+ [NFT_MSG_DELRULE] = AUDIT_NFT_OP_RULE_UNREGISTER,
+ [NFT_MSG_NEWSET] = AUDIT_NFT_OP_SET_REGISTER,
+ [NFT_MSG_GETSET] = AUDIT_NFT_OP_INVALID,
+ [NFT_MSG_DELSET] = AUDIT_NFT_OP_SET_UNREGISTER,
+ [NFT_MSG_NEWSETELEM] = AUDIT_NFT_OP_SETELEM_REGISTER,
+ [NFT_MSG_GETSETELEM] = AUDIT_NFT_OP_INVALID,
+ [NFT_MSG_DELSETELEM] = AUDIT_NFT_OP_SETELEM_UNREGISTER,
+ [NFT_MSG_NEWGEN] = AUDIT_NFT_OP_GEN_REGISTER,
+ [NFT_MSG_GETGEN] = AUDIT_NFT_OP_INVALID,
+ [NFT_MSG_TRACE] = AUDIT_NFT_OP_INVALID,
+ [NFT_MSG_NEWOBJ] = AUDIT_NFT_OP_OBJ_REGISTER,
+ [NFT_MSG_GETOBJ] = AUDIT_NFT_OP_INVALID,
+ [NFT_MSG_DELOBJ] = AUDIT_NFT_OP_OBJ_UNREGISTER,
+ [NFT_MSG_GETOBJ_RESET] = AUDIT_NFT_OP_OBJ_RESET,
+ [NFT_MSG_NEWFLOWTABLE] = AUDIT_NFT_OP_FLOWTABLE_REGISTER,
+ [NFT_MSG_GETFLOWTABLE] = AUDIT_NFT_OP_INVALID,
+ [NFT_MSG_DELFLOWTABLE] = AUDIT_NFT_OP_FLOWTABLE_UNREGISTER,
+};
+
static void nft_validate_state_update(struct net *net, u8 new_validate_state)
{
switch (net->nft.validate_state) {
@@ -717,17 +752,6 @@ static void nf_tables_table_notify(const struct nft_ctx *ctx, int event)
{
struct sk_buff *skb;
int err;
- char *buf = kasprintf(GFP_KERNEL, "%s:%llu;?:0",
- ctx->table->name, ctx->table->handle);
-
- audit_log_nfcfg(buf,
- ctx->family,
- ctx->table->use,
- event == NFT_MSG_NEWTABLE ?
- AUDIT_NFT_OP_TABLE_REGISTER :
- AUDIT_NFT_OP_TABLE_UNREGISTER,
- GFP_KERNEL);
- kfree(buf);
if (!ctx->report &&
!nfnetlink_has_listeners(ctx->net, NFNLGRP_NFTABLES))
@@ -1491,18 +1515,6 @@ static void nf_tables_chain_notify(const struct nft_ctx *ctx, int event)
{
struct sk_buff *skb;
int err;
- char *buf = kasprintf(GFP_KERNEL, "%s:%llu;%s:%llu",
- ctx->table->name, ctx->table->handle,
- ctx->chain->name, ctx->chain->handle);
-
- audit_log_nfcfg(buf,
- ctx->family,
- ctx->chain->use,
- event == NFT_MSG_NEWCHAIN ?
- AUDIT_NFT_OP_CHAIN_REGISTER :
- AUDIT_NFT_OP_CHAIN_UNREGISTER,
- GFP_KERNEL);
- kfree(buf);
if (!ctx->report &&
!nfnetlink_has_listeners(ctx->net, NFNLGRP_NFTABLES))
@@ -2855,18 +2867,6 @@ static void nf_tables_rule_notify(const struct nft_ctx *ctx,
{
struct sk_buff *skb;
int err;
- char *buf = kasprintf(GFP_KERNEL, "%s:%llu;%s:%llu",
- ctx->table->name, ctx->table->handle,
- ctx->chain->name, ctx->chain->handle);
-
- audit_log_nfcfg(buf,
- ctx->family,
- rule->handle,
- event == NFT_MSG_NEWRULE ?
- AUDIT_NFT_OP_RULE_REGISTER :
- AUDIT_NFT_OP_RULE_UNREGISTER,
- GFP_KERNEL);
- kfree(buf);
if (!ctx->report &&
!nfnetlink_has_listeners(ctx->net, NFNLGRP_NFTABLES))
@@ -3901,18 +3901,6 @@ static void nf_tables_set_notify(const struct nft_ctx *ctx,
struct sk_buff *skb;
u32 portid = ctx->portid;
int err;
- char *buf = kasprintf(gfp_flags, "%s:%llu;%s:%llu",
- ctx->table->name, ctx->table->handle,
- set->name, set->handle);
-
- audit_log_nfcfg(buf,
- ctx->family,
- set->field_count,
- event == NFT_MSG_NEWSET ?
- AUDIT_NFT_OP_SET_REGISTER :
- AUDIT_NFT_OP_SET_UNREGISTER,
- gfp_flags);
- kfree(buf);
if (!ctx->report &&
!nfnetlink_has_listeners(ctx->net, NFNLGRP_NFTABLES))
@@ -5097,18 +5085,6 @@ static void nf_tables_setelem_notify(const struct nft_ctx *ctx,
u32 portid = ctx->portid;
struct sk_buff *skb;
int err;
- char *buf = kasprintf(GFP_KERNEL, "%s:%llu;%s:%llu",
- ctx->table->name, ctx->table->handle,
- set->name, set->handle);
-
- audit_log_nfcfg(buf,
- ctx->family,
- set->handle,
- event == NFT_MSG_NEWSETELEM ?
- AUDIT_NFT_OP_SETELEM_REGISTER :
- AUDIT_NFT_OP_SETELEM_UNREGISTER,
- GFP_KERNEL);
- kfree(buf);
if (!ctx->report && !nfnetlink_has_listeners(net, NFNLGRP_NFTABLES))
return;
@@ -6310,12 +6286,11 @@ static int nf_tables_dump_obj(struct sk_buff *skb, struct netlink_callback *cb)
filter->type != NFT_OBJECT_UNSPEC &&
obj->ops->type->type != filter->type)
goto cont;
-
if (reset) {
char *buf = kasprintf(GFP_ATOMIC,
- "%s:%llu;?:0",
+ "%s:%u",
table->name,
- table->handle);
+ net->nft.base_seq);
audit_log_nfcfg(buf,
family,
@@ -6436,8 +6411,8 @@ static int nf_tables_getobj(struct net *net, struct sock *nlsk,
reset = true;
if (reset) {
- char *buf = kasprintf(GFP_ATOMIC, "%s:%llu;?:0",
- table->name, table->handle);
+ char *buf = kasprintf(GFP_ATOMIC, "%s:%u",
+ table->name, net->nft.base_seq);
audit_log_nfcfg(buf,
family,
@@ -6525,15 +6500,15 @@ void nft_obj_notify(struct net *net, const struct nft_table *table,
{
struct sk_buff *skb;
int err;
- char *buf = kasprintf(gfp, "%s:%llu;?:0",
- table->name, table->handle);
+ char *buf = kasprintf(gfp, "%s:%u",
+ table->name, net->nft.base_seq);
audit_log_nfcfg(buf,
family,
obj->handle,
event == NFT_MSG_NEWOBJ ?
- AUDIT_NFT_OP_OBJ_REGISTER :
- AUDIT_NFT_OP_OBJ_UNREGISTER,
+ AUDIT_NFT_OP_OBJ_REGISTER :
+ AUDIT_NFT_OP_OBJ_UNREGISTER,
gfp);
kfree(buf);
@@ -7333,18 +7308,6 @@ static void nf_tables_flowtable_notify(struct nft_ctx *ctx,
{
struct sk_buff *skb;
int err;
- char *buf = kasprintf(GFP_KERNEL, "%s:%llu;%s:%llu",
- flowtable->table->name, flowtable->table->handle,
- flowtable->name, flowtable->handle);
-
- audit_log_nfcfg(buf,
- ctx->family,
- flowtable->hooknum,
- event == NFT_MSG_NEWFLOWTABLE ?
- AUDIT_NFT_OP_FLOWTABLE_REGISTER :
- AUDIT_NFT_OP_FLOWTABLE_UNREGISTER,
- GFP_KERNEL);
- kfree(buf);
if (!ctx->report &&
!nfnetlink_has_listeners(ctx->net, NFNLGRP_NFTABLES))
@@ -7465,9 +7428,6 @@ static void nf_tables_gen_notify(struct net *net, struct sk_buff *skb,
struct sk_buff *skb2;
int err;
- audit_log_nfcfg("?:0;?:0", 0, net->nft.base_seq,
- AUDIT_NFT_OP_GEN_REGISTER, GFP_KERNEL);
-
if (!nlmsg_report(nlh) &&
!nfnetlink_has_listeners(net, NFNLGRP_NFTABLES))
return;
@@ -8006,12 +7966,65 @@ static void nft_commit_notify(struct net *net, u32 portid)
WARN_ON_ONCE(!list_empty(&net->nft.notify_list));
}
+static int nf_tables_commit_audit_alloc(struct list_head *adl,
+ struct nft_table *table)
+{
+ struct nft_audit_data *adp;
+
+ list_for_each_entry(adp, adl, list) {
+ if (adp->table == table)
+ return 0;
+ }
+ adp = kzalloc(sizeof(*adp), GFP_KERNEL);
+ if (!adp)
+ return -ENOMEM;
+ adp->table = table;
+ INIT_LIST_HEAD(&adp->list);
+ list_add(&adp->list, adl);
+ return 0;
+}
+
+static void nf_tables_commit_audit_collect(struct list_head *adl,
+ struct nft_table *table, u32 op)
+{
+ struct nft_audit_data *adp;
+
+ list_for_each_entry(adp, adl, list) {
+ if (adp->table == table)
+ goto found;
+ }
+ WARN_ONCE("table=%s not expected in commit list", table->name);
+ return;
+found:
+ adp->entries++;
+ if (!adp->op || adp->op > op)
+ adp->op = op;
+}
+
+#define AUNFTABLENAMELEN (NFT_TABLE_MAXNAMELEN + 22)
+
+static void nf_tables_commit_audit_log(struct list_head *adl, u32 generation)
+{
+ struct nft_audit_data *adp, *adn;
+ char aubuf[AUNFTABLENAMELEN];
+
+ list_for_each_entry_safe(adp, adn, adl, list) {
+ snprintf(aubuf, AUNFTABLENAMELEN, "%s:%u", adp->table->name,
+ generation);
+ audit_log_nfcfg(aubuf, adp->table->family, adp->entries,
+ nft2audit_op[adp->op], GFP_KERNEL);
+ list_del(&adp->list);
+ kfree(adp);
+ }
+}
+
static int nf_tables_commit(struct net *net, struct sk_buff *skb)
{
struct nft_trans *trans, *next;
struct nft_trans_elem *te;
struct nft_chain *chain;
struct nft_table *table;
+ LIST_HEAD(adl);
int err;
if (list_empty(&net->nft.commit_list)) {
@@ -8031,6 +8044,11 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb)
list_for_each_entry_safe(trans, next, &net->nft.commit_list, list) {
int ret;
+ ret = nf_tables_commit_audit_alloc(&adl, trans->ctx.table);
+ if (ret) {
+ nf_tables_commit_chain_prepare_cancel(net);
+ return ret;
+ }
if (trans->msg_type == NFT_MSG_NEWRULE ||
trans->msg_type == NFT_MSG_DELRULE) {
chain = trans->ctx.chain;
@@ -8206,10 +8224,13 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb)
}
break;
}
+ nf_tables_commit_audit_collect(&adl, trans->ctx.table,
+ trans->msg_type);
}
nft_commit_notify(net, NETLINK_CB(skb).portid);
nf_tables_gen_notify(net, skb, NFT_MSG_NEWGEN);
+ nf_tables_commit_audit_log(&adl, net->nft.base_seq);
nf_tables_commit_release(net);
return 0;
--
2.27.0
--
Linux-audit mailing list
Linux-audit@redhat.com
https://listman.redhat.com/mailman/listinfo/linux-audit
^ permalink raw reply related [flat|nested] 22+ messages in thread* [PATCH v5] audit: log nftables configuration change events once per table @ 2021-03-26 17:38 ` Richard Guy Briggs 0 siblings, 0 replies; 22+ messages in thread From: Richard Guy Briggs @ 2021-03-26 17:38 UTC (permalink / raw) To: Linux-Audit Mailing List, LKML, netfilter-devel Cc: Paul Moore, Eric Paris, Steve Grubb, Richard Guy Briggs, Florian Westphal, Phil Sutter, twoerner, tgraf, dan.carpenter, Jones Desougi Reduce logging of nftables events to a level similar to iptables. Restore the table field to list the table, adding the generation. Indicate the op as the most significant operation in the event. A couple of sample events: type=PROCTITLE msg=audit(2021-03-18 09:30:49.801:143) : proctitle=/usr/bin/python3 -s /usr/sbin/firewalld --nofork --nopid type=SYSCALL msg=audit(2021-03-18 09:30:49.801:143) : arch=x86_64 syscall=sendmsg success=yes exit=172 a0=0x6 a1=0x7ffdcfcbe650 a2=0x0 a3=0x7ffdcfcbd52c items=0 ppid=1 pid=367 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=roo t sgid=root fsgid=root tty=(none) ses=unset comm=firewalld exe=/usr/bin/python3.9 subj=system_u:system_r:firewalld_t:s0 key=(null) type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.801:143) : table=firewalld:2 family=ipv6 entries=1 op=nft_register_table pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.801:143) : table=firewalld:2 family=ipv4 entries=1 op=nft_register_table pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.801:143) : table=firewalld:2 family=inet entries=1 op=nft_register_table pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld type=PROCTITLE msg=audit(2021-03-18 09:30:49.839:144) : proctitle=/usr/bin/python3 -s /usr/sbin/firewalld --nofork --nopid type=SYSCALL msg=audit(2021-03-18 09:30:49.839:144) : arch=x86_64 syscall=sendmsg success=yes exit=22792 a0=0x6 a1=0x7ffdcfcbe650 a2=0x0 a3=0x7ffdcfcbd52c items=0 ppid=1 pid=367 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=r oot sgid=root fsgid=root tty=(none) ses=unset comm=firewalld exe=/usr/bin/python3.9 subj=system_u:system_r:firewalld_t:s0 key=(null) type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.839:144) : table=firewalld:3 family=ipv6 entries=30 op=nft_register_chain pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.839:144) : table=firewalld:3 family=ipv4 entries=30 op=nft_register_chain pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.839:144) : table=firewalld:3 family=inet entries=165 op=nft_register_chain pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld The issue was originally documented in https://github.com/linux-audit/audit-kernel/issues/124 Signed-off-by: Richard Guy Briggs <rgb@redhat.com> --- Changelog: v5: (sorry for all the noise...) - fix kbuild missing prototype warning in nf_tables_commit_audit_{alloc,collect,log}() <lkp@intel.com> v4: - move nf_tables_commit_audit_log() before nf_tables_commit_release() [fw] - move nft2audit_op[] from audit.h to nf_tables_api.c v3: - fix function braces, reduce parameter scope [pna] - pre-allocate nft_audit_data per table in step 1, bail on ENOMEM [pna] v2: - convert NFT ops to array indicies in nft2audit_op[] [ps] - use linux lists [pna] - use functions for each of collection and logging of audit data [pna] --- net/netfilter/nf_tables_api.c | 187 +++++++++++++++++++--------------- 1 file changed, 104 insertions(+), 83 deletions(-) diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c index c1eb5cdb3033..ef51abe3a6d7 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -66,6 +66,41 @@ static const struct rhashtable_params nft_objname_ht_params = { .automatic_shrinking = true, }; +struct nft_audit_data { + struct nft_table *table; + int entries; + int op; + struct list_head list; +}; + +static const u8 nft2audit_op[NFT_MSG_MAX] = { // enum nf_tables_msg_types + [NFT_MSG_NEWTABLE] = AUDIT_NFT_OP_TABLE_REGISTER, + [NFT_MSG_GETTABLE] = AUDIT_NFT_OP_INVALID, + [NFT_MSG_DELTABLE] = AUDIT_NFT_OP_TABLE_UNREGISTER, + [NFT_MSG_NEWCHAIN] = AUDIT_NFT_OP_CHAIN_REGISTER, + [NFT_MSG_GETCHAIN] = AUDIT_NFT_OP_INVALID, + [NFT_MSG_DELCHAIN] = AUDIT_NFT_OP_CHAIN_UNREGISTER, + [NFT_MSG_NEWRULE] = AUDIT_NFT_OP_RULE_REGISTER, + [NFT_MSG_GETRULE] = AUDIT_NFT_OP_INVALID, + [NFT_MSG_DELRULE] = AUDIT_NFT_OP_RULE_UNREGISTER, + [NFT_MSG_NEWSET] = AUDIT_NFT_OP_SET_REGISTER, + [NFT_MSG_GETSET] = AUDIT_NFT_OP_INVALID, + [NFT_MSG_DELSET] = AUDIT_NFT_OP_SET_UNREGISTER, + [NFT_MSG_NEWSETELEM] = AUDIT_NFT_OP_SETELEM_REGISTER, + [NFT_MSG_GETSETELEM] = AUDIT_NFT_OP_INVALID, + [NFT_MSG_DELSETELEM] = AUDIT_NFT_OP_SETELEM_UNREGISTER, + [NFT_MSG_NEWGEN] = AUDIT_NFT_OP_GEN_REGISTER, + [NFT_MSG_GETGEN] = AUDIT_NFT_OP_INVALID, + [NFT_MSG_TRACE] = AUDIT_NFT_OP_INVALID, + [NFT_MSG_NEWOBJ] = AUDIT_NFT_OP_OBJ_REGISTER, + [NFT_MSG_GETOBJ] = AUDIT_NFT_OP_INVALID, + [NFT_MSG_DELOBJ] = AUDIT_NFT_OP_OBJ_UNREGISTER, + [NFT_MSG_GETOBJ_RESET] = AUDIT_NFT_OP_OBJ_RESET, + [NFT_MSG_NEWFLOWTABLE] = AUDIT_NFT_OP_FLOWTABLE_REGISTER, + [NFT_MSG_GETFLOWTABLE] = AUDIT_NFT_OP_INVALID, + [NFT_MSG_DELFLOWTABLE] = AUDIT_NFT_OP_FLOWTABLE_UNREGISTER, +}; + static void nft_validate_state_update(struct net *net, u8 new_validate_state) { switch (net->nft.validate_state) { @@ -717,17 +752,6 @@ static void nf_tables_table_notify(const struct nft_ctx *ctx, int event) { struct sk_buff *skb; int err; - char *buf = kasprintf(GFP_KERNEL, "%s:%llu;?:0", - ctx->table->name, ctx->table->handle); - - audit_log_nfcfg(buf, - ctx->family, - ctx->table->use, - event == NFT_MSG_NEWTABLE ? - AUDIT_NFT_OP_TABLE_REGISTER : - AUDIT_NFT_OP_TABLE_UNREGISTER, - GFP_KERNEL); - kfree(buf); if (!ctx->report && !nfnetlink_has_listeners(ctx->net, NFNLGRP_NFTABLES)) @@ -1491,18 +1515,6 @@ static void nf_tables_chain_notify(const struct nft_ctx *ctx, int event) { struct sk_buff *skb; int err; - char *buf = kasprintf(GFP_KERNEL, "%s:%llu;%s:%llu", - ctx->table->name, ctx->table->handle, - ctx->chain->name, ctx->chain->handle); - - audit_log_nfcfg(buf, - ctx->family, - ctx->chain->use, - event == NFT_MSG_NEWCHAIN ? - AUDIT_NFT_OP_CHAIN_REGISTER : - AUDIT_NFT_OP_CHAIN_UNREGISTER, - GFP_KERNEL); - kfree(buf); if (!ctx->report && !nfnetlink_has_listeners(ctx->net, NFNLGRP_NFTABLES)) @@ -2855,18 +2867,6 @@ static void nf_tables_rule_notify(const struct nft_ctx *ctx, { struct sk_buff *skb; int err; - char *buf = kasprintf(GFP_KERNEL, "%s:%llu;%s:%llu", - ctx->table->name, ctx->table->handle, - ctx->chain->name, ctx->chain->handle); - - audit_log_nfcfg(buf, - ctx->family, - rule->handle, - event == NFT_MSG_NEWRULE ? - AUDIT_NFT_OP_RULE_REGISTER : - AUDIT_NFT_OP_RULE_UNREGISTER, - GFP_KERNEL); - kfree(buf); if (!ctx->report && !nfnetlink_has_listeners(ctx->net, NFNLGRP_NFTABLES)) @@ -3901,18 +3901,6 @@ static void nf_tables_set_notify(const struct nft_ctx *ctx, struct sk_buff *skb; u32 portid = ctx->portid; int err; - char *buf = kasprintf(gfp_flags, "%s:%llu;%s:%llu", - ctx->table->name, ctx->table->handle, - set->name, set->handle); - - audit_log_nfcfg(buf, - ctx->family, - set->field_count, - event == NFT_MSG_NEWSET ? - AUDIT_NFT_OP_SET_REGISTER : - AUDIT_NFT_OP_SET_UNREGISTER, - gfp_flags); - kfree(buf); if (!ctx->report && !nfnetlink_has_listeners(ctx->net, NFNLGRP_NFTABLES)) @@ -5097,18 +5085,6 @@ static void nf_tables_setelem_notify(const struct nft_ctx *ctx, u32 portid = ctx->portid; struct sk_buff *skb; int err; - char *buf = kasprintf(GFP_KERNEL, "%s:%llu;%s:%llu", - ctx->table->name, ctx->table->handle, - set->name, set->handle); - - audit_log_nfcfg(buf, - ctx->family, - set->handle, - event == NFT_MSG_NEWSETELEM ? - AUDIT_NFT_OP_SETELEM_REGISTER : - AUDIT_NFT_OP_SETELEM_UNREGISTER, - GFP_KERNEL); - kfree(buf); if (!ctx->report && !nfnetlink_has_listeners(net, NFNLGRP_NFTABLES)) return; @@ -6310,12 +6286,11 @@ static int nf_tables_dump_obj(struct sk_buff *skb, struct netlink_callback *cb) filter->type != NFT_OBJECT_UNSPEC && obj->ops->type->type != filter->type) goto cont; - if (reset) { char *buf = kasprintf(GFP_ATOMIC, - "%s:%llu;?:0", + "%s:%u", table->name, - table->handle); + net->nft.base_seq); audit_log_nfcfg(buf, family, @@ -6436,8 +6411,8 @@ static int nf_tables_getobj(struct net *net, struct sock *nlsk, reset = true; if (reset) { - char *buf = kasprintf(GFP_ATOMIC, "%s:%llu;?:0", - table->name, table->handle); + char *buf = kasprintf(GFP_ATOMIC, "%s:%u", + table->name, net->nft.base_seq); audit_log_nfcfg(buf, family, @@ -6525,15 +6500,15 @@ void nft_obj_notify(struct net *net, const struct nft_table *table, { struct sk_buff *skb; int err; - char *buf = kasprintf(gfp, "%s:%llu;?:0", - table->name, table->handle); + char *buf = kasprintf(gfp, "%s:%u", + table->name, net->nft.base_seq); audit_log_nfcfg(buf, family, obj->handle, event == NFT_MSG_NEWOBJ ? - AUDIT_NFT_OP_OBJ_REGISTER : - AUDIT_NFT_OP_OBJ_UNREGISTER, + AUDIT_NFT_OP_OBJ_REGISTER : + AUDIT_NFT_OP_OBJ_UNREGISTER, gfp); kfree(buf); @@ -7333,18 +7308,6 @@ static void nf_tables_flowtable_notify(struct nft_ctx *ctx, { struct sk_buff *skb; int err; - char *buf = kasprintf(GFP_KERNEL, "%s:%llu;%s:%llu", - flowtable->table->name, flowtable->table->handle, - flowtable->name, flowtable->handle); - - audit_log_nfcfg(buf, - ctx->family, - flowtable->hooknum, - event == NFT_MSG_NEWFLOWTABLE ? - AUDIT_NFT_OP_FLOWTABLE_REGISTER : - AUDIT_NFT_OP_FLOWTABLE_UNREGISTER, - GFP_KERNEL); - kfree(buf); if (!ctx->report && !nfnetlink_has_listeners(ctx->net, NFNLGRP_NFTABLES)) @@ -7465,9 +7428,6 @@ static void nf_tables_gen_notify(struct net *net, struct sk_buff *skb, struct sk_buff *skb2; int err; - audit_log_nfcfg("?:0;?:0", 0, net->nft.base_seq, - AUDIT_NFT_OP_GEN_REGISTER, GFP_KERNEL); - if (!nlmsg_report(nlh) && !nfnetlink_has_listeners(net, NFNLGRP_NFTABLES)) return; @@ -8006,12 +7966,65 @@ static void nft_commit_notify(struct net *net, u32 portid) WARN_ON_ONCE(!list_empty(&net->nft.notify_list)); } +static int nf_tables_commit_audit_alloc(struct list_head *adl, + struct nft_table *table) +{ + struct nft_audit_data *adp; + + list_for_each_entry(adp, adl, list) { + if (adp->table == table) + return 0; + } + adp = kzalloc(sizeof(*adp), GFP_KERNEL); + if (!adp) + return -ENOMEM; + adp->table = table; + INIT_LIST_HEAD(&adp->list); + list_add(&adp->list, adl); + return 0; +} + +static void nf_tables_commit_audit_collect(struct list_head *adl, + struct nft_table *table, u32 op) +{ + struct nft_audit_data *adp; + + list_for_each_entry(adp, adl, list) { + if (adp->table == table) + goto found; + } + WARN_ONCE("table=%s not expected in commit list", table->name); + return; +found: + adp->entries++; + if (!adp->op || adp->op > op) + adp->op = op; +} + +#define AUNFTABLENAMELEN (NFT_TABLE_MAXNAMELEN + 22) + +static void nf_tables_commit_audit_log(struct list_head *adl, u32 generation) +{ + struct nft_audit_data *adp, *adn; + char aubuf[AUNFTABLENAMELEN]; + + list_for_each_entry_safe(adp, adn, adl, list) { + snprintf(aubuf, AUNFTABLENAMELEN, "%s:%u", adp->table->name, + generation); + audit_log_nfcfg(aubuf, adp->table->family, adp->entries, + nft2audit_op[adp->op], GFP_KERNEL); + list_del(&adp->list); + kfree(adp); + } +} + static int nf_tables_commit(struct net *net, struct sk_buff *skb) { struct nft_trans *trans, *next; struct nft_trans_elem *te; struct nft_chain *chain; struct nft_table *table; + LIST_HEAD(adl); int err; if (list_empty(&net->nft.commit_list)) { @@ -8031,6 +8044,11 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb) list_for_each_entry_safe(trans, next, &net->nft.commit_list, list) { int ret; + ret = nf_tables_commit_audit_alloc(&adl, trans->ctx.table); + if (ret) { + nf_tables_commit_chain_prepare_cancel(net); + return ret; + } if (trans->msg_type == NFT_MSG_NEWRULE || trans->msg_type == NFT_MSG_DELRULE) { chain = trans->ctx.chain; @@ -8206,10 +8224,13 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb) } break; } + nf_tables_commit_audit_collect(&adl, trans->ctx.table, + trans->msg_type); } nft_commit_notify(net, NETLINK_CB(skb).portid); nf_tables_gen_notify(net, skb, NFT_MSG_NEWGEN); + nf_tables_commit_audit_log(&adl, net->nft.base_seq); nf_tables_commit_release(net); return 0; -- 2.27.0 ^ permalink raw reply related [flat|nested] 22+ messages in thread
* Re: [PATCH v5] audit: log nftables configuration change events once per table 2021-03-26 17:38 ` Richard Guy Briggs @ 2021-03-29 0:50 ` Paul Moore -1 siblings, 0 replies; 22+ messages in thread From: Paul Moore @ 2021-03-29 0:50 UTC (permalink / raw) To: Richard Guy Briggs Cc: Jones Desougi, Phil Sutter, Florian Westphal, LKML, Linux-Audit Mailing List, netfilter-devel, twoerner, Eric Paris, tgraf, dan.carpenter On Fri, Mar 26, 2021 at 1:39 PM Richard Guy Briggs <rgb@redhat.com> wrote: > > Reduce logging of nftables events to a level similar to iptables. > Restore the table field to list the table, adding the generation. > > Indicate the op as the most significant operation in the event. > > A couple of sample events: > > type=PROCTITLE msg=audit(2021-03-18 09:30:49.801:143) : proctitle=/usr/bin/python3 -s /usr/sbin/firewalld --nofork --nopid > type=SYSCALL msg=audit(2021-03-18 09:30:49.801:143) : arch=x86_64 syscall=sendmsg success=yes exit=172 a0=0x6 a1=0x7ffdcfcbe650 a2=0x0 a3=0x7ffdcfcbd52c items=0 ppid=1 pid=367 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=roo > t sgid=root fsgid=root tty=(none) ses=unset comm=firewalld exe=/usr/bin/python3.9 subj=system_u:system_r:firewalld_t:s0 key=(null) > type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.801:143) : table=firewalld:2 family=ipv6 entries=1 op=nft_register_table pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld > type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.801:143) : table=firewalld:2 family=ipv4 entries=1 op=nft_register_table pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld > type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.801:143) : table=firewalld:2 family=inet entries=1 op=nft_register_table pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld > > type=PROCTITLE msg=audit(2021-03-18 09:30:49.839:144) : proctitle=/usr/bin/python3 -s /usr/sbin/firewalld --nofork --nopid > type=SYSCALL msg=audit(2021-03-18 09:30:49.839:144) : arch=x86_64 syscall=sendmsg success=yes exit=22792 a0=0x6 a1=0x7ffdcfcbe650 a2=0x0 a3=0x7ffdcfcbd52c items=0 ppid=1 pid=367 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=r > oot sgid=root fsgid=root tty=(none) ses=unset comm=firewalld exe=/usr/bin/python3.9 subj=system_u:system_r:firewalld_t:s0 key=(null) > type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.839:144) : table=firewalld:3 family=ipv6 entries=30 op=nft_register_chain pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld > type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.839:144) : table=firewalld:3 family=ipv4 entries=30 op=nft_register_chain pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld > type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.839:144) : table=firewalld:3 family=inet entries=165 op=nft_register_chain pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld > > The issue was originally documented in > https://github.com/linux-audit/audit-kernel/issues/124 > > Signed-off-by: Richard Guy Briggs <rgb@redhat.com> > --- > Changelog: > v5: > (sorry for all the noise...) > - fix kbuild missing prototype warning in nf_tables_commit_audit_{alloc,collect,log}() <lkp@intel.com> > > v4: > - move nf_tables_commit_audit_log() before nf_tables_commit_release() [fw] > - move nft2audit_op[] from audit.h to nf_tables_api.c > > v3: > - fix function braces, reduce parameter scope [pna] > - pre-allocate nft_audit_data per table in step 1, bail on ENOMEM [pna] > > v2: > - convert NFT ops to array indicies in nft2audit_op[] [ps] > - use linux lists [pna] > - use functions for each of collection and logging of audit data [pna] > --- > net/netfilter/nf_tables_api.c | 187 +++++++++++++++++++--------------- > 1 file changed, 104 insertions(+), 83 deletions(-) Netfilter folks, were you planning to pull this via your tree/netdev or would you like me to merge this via the audit tree? If the latter, I would appreciate it if I could get an ACK from one of you; if the former, my ACK is below. Acked-by: Paul Moore <paul@paul-moore.com> -- paul moore www.paul-moore.com -- Linux-audit mailing list Linux-audit@redhat.com https://listman.redhat.com/mailman/listinfo/linux-audit ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v5] audit: log nftables configuration change events once per table @ 2021-03-29 0:50 ` Paul Moore 0 siblings, 0 replies; 22+ messages in thread From: Paul Moore @ 2021-03-29 0:50 UTC (permalink / raw) To: Richard Guy Briggs Cc: Linux-Audit Mailing List, LKML, netfilter-devel, Eric Paris, Steve Grubb, Florian Westphal, Phil Sutter, twoerner, tgraf, dan.carpenter, Jones Desougi On Fri, Mar 26, 2021 at 1:39 PM Richard Guy Briggs <rgb@redhat.com> wrote: > > Reduce logging of nftables events to a level similar to iptables. > Restore the table field to list the table, adding the generation. > > Indicate the op as the most significant operation in the event. > > A couple of sample events: > > type=PROCTITLE msg=audit(2021-03-18 09:30:49.801:143) : proctitle=/usr/bin/python3 -s /usr/sbin/firewalld --nofork --nopid > type=SYSCALL msg=audit(2021-03-18 09:30:49.801:143) : arch=x86_64 syscall=sendmsg success=yes exit=172 a0=0x6 a1=0x7ffdcfcbe650 a2=0x0 a3=0x7ffdcfcbd52c items=0 ppid=1 pid=367 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=roo > t sgid=root fsgid=root tty=(none) ses=unset comm=firewalld exe=/usr/bin/python3.9 subj=system_u:system_r:firewalld_t:s0 key=(null) > type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.801:143) : table=firewalld:2 family=ipv6 entries=1 op=nft_register_table pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld > type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.801:143) : table=firewalld:2 family=ipv4 entries=1 op=nft_register_table pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld > type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.801:143) : table=firewalld:2 family=inet entries=1 op=nft_register_table pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld > > type=PROCTITLE msg=audit(2021-03-18 09:30:49.839:144) : proctitle=/usr/bin/python3 -s /usr/sbin/firewalld --nofork --nopid > type=SYSCALL msg=audit(2021-03-18 09:30:49.839:144) : arch=x86_64 syscall=sendmsg success=yes exit=22792 a0=0x6 a1=0x7ffdcfcbe650 a2=0x0 a3=0x7ffdcfcbd52c items=0 ppid=1 pid=367 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=r > oot sgid=root fsgid=root tty=(none) ses=unset comm=firewalld exe=/usr/bin/python3.9 subj=system_u:system_r:firewalld_t:s0 key=(null) > type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.839:144) : table=firewalld:3 family=ipv6 entries=30 op=nft_register_chain pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld > type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.839:144) : table=firewalld:3 family=ipv4 entries=30 op=nft_register_chain pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld > type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.839:144) : table=firewalld:3 family=inet entries=165 op=nft_register_chain pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld > > The issue was originally documented in > https://github.com/linux-audit/audit-kernel/issues/124 > > Signed-off-by: Richard Guy Briggs <rgb@redhat.com> > --- > Changelog: > v5: > (sorry for all the noise...) > - fix kbuild missing prototype warning in nf_tables_commit_audit_{alloc,collect,log}() <lkp@intel.com> > > v4: > - move nf_tables_commit_audit_log() before nf_tables_commit_release() [fw] > - move nft2audit_op[] from audit.h to nf_tables_api.c > > v3: > - fix function braces, reduce parameter scope [pna] > - pre-allocate nft_audit_data per table in step 1, bail on ENOMEM [pna] > > v2: > - convert NFT ops to array indicies in nft2audit_op[] [ps] > - use linux lists [pna] > - use functions for each of collection and logging of audit data [pna] > --- > net/netfilter/nf_tables_api.c | 187 +++++++++++++++++++--------------- > 1 file changed, 104 insertions(+), 83 deletions(-) Netfilter folks, were you planning to pull this via your tree/netdev or would you like me to merge this via the audit tree? If the latter, I would appreciate it if I could get an ACK from one of you; if the former, my ACK is below. Acked-by: Paul Moore <paul@paul-moore.com> -- paul moore www.paul-moore.com ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v5] audit: log nftables configuration change events once per table 2021-03-29 0:50 ` Paul Moore @ 2021-03-30 22:53 ` Pablo Neira Ayuso -1 siblings, 0 replies; 22+ messages in thread From: Pablo Neira Ayuso @ 2021-03-30 22:53 UTC (permalink / raw) To: Paul Moore Cc: Jones Desougi, Richard Guy Briggs, Phil Sutter, Florian Westphal, LKML, Linux-Audit Mailing List, netfilter-devel, twoerner, Eric Paris, tgraf, dan.carpenter On Sun, Mar 28, 2021 at 08:50:45PM -0400, Paul Moore wrote: [...] > Netfilter folks, were you planning to pull this via your tree/netdev > or would you like me to merge this via the audit tree? If the latter, > I would appreciate it if I could get an ACK from one of you; if the > former, my ACK is below. > > Acked-by: Paul Moore <paul@paul-moore.com> I'll merge this one into nf-next, this might simplify possible conflict resolution later on. Thanks for acking. -- Linux-audit mailing list Linux-audit@redhat.com https://listman.redhat.com/mailman/listinfo/linux-audit ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v5] audit: log nftables configuration change events once per table @ 2021-03-30 22:53 ` Pablo Neira Ayuso 0 siblings, 0 replies; 22+ messages in thread From: Pablo Neira Ayuso @ 2021-03-30 22:53 UTC (permalink / raw) To: Paul Moore Cc: Richard Guy Briggs, Linux-Audit Mailing List, LKML, netfilter-devel, Eric Paris, Steve Grubb, Florian Westphal, Phil Sutter, twoerner, tgraf, dan.carpenter, Jones Desougi On Sun, Mar 28, 2021 at 08:50:45PM -0400, Paul Moore wrote: [...] > Netfilter folks, were you planning to pull this via your tree/netdev > or would you like me to merge this via the audit tree? If the latter, > I would appreciate it if I could get an ACK from one of you; if the > former, my ACK is below. > > Acked-by: Paul Moore <paul@paul-moore.com> I'll merge this one into nf-next, this might simplify possible conflict resolution later on. Thanks for acking. ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v5] audit: log nftables configuration change events once per table 2021-03-30 22:53 ` Pablo Neira Ayuso @ 2021-03-31 0:50 ` Paul Moore -1 siblings, 0 replies; 22+ messages in thread From: Paul Moore @ 2021-03-31 0:50 UTC (permalink / raw) To: Pablo Neira Ayuso Cc: Jones Desougi, Richard Guy Briggs, Phil Sutter, Florian Westphal, LKML, Linux-Audit Mailing List, netfilter-devel, twoerner, Eric Paris, tgraf, dan.carpenter On Tue, Mar 30, 2021 at 6:53 PM Pablo Neira Ayuso <pablo@netfilter.org> wrote: > On Sun, Mar 28, 2021 at 08:50:45PM -0400, Paul Moore wrote: > [...] > > Netfilter folks, were you planning to pull this via your tree/netdev > > or would you like me to merge this via the audit tree? If the latter, > > I would appreciate it if I could get an ACK from one of you; if the > > former, my ACK is below. > > > > Acked-by: Paul Moore <paul@paul-moore.com> > > I'll merge this one into nf-next, this might simplify possible > conflict resolution later on. Yep, I think that's the best choice. Thanks. -- paul moore www.paul-moore.com -- Linux-audit mailing list Linux-audit@redhat.com https://listman.redhat.com/mailman/listinfo/linux-audit ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v5] audit: log nftables configuration change events once per table @ 2021-03-31 0:50 ` Paul Moore 0 siblings, 0 replies; 22+ messages in thread From: Paul Moore @ 2021-03-31 0:50 UTC (permalink / raw) To: Pablo Neira Ayuso Cc: Richard Guy Briggs, Linux-Audit Mailing List, LKML, netfilter-devel, Eric Paris, Steve Grubb, Florian Westphal, Phil Sutter, twoerner, tgraf, dan.carpenter, Jones Desougi On Tue, Mar 30, 2021 at 6:53 PM Pablo Neira Ayuso <pablo@netfilter.org> wrote: > On Sun, Mar 28, 2021 at 08:50:45PM -0400, Paul Moore wrote: > [...] > > Netfilter folks, were you planning to pull this via your tree/netdev > > or would you like me to merge this via the audit tree? If the latter, > > I would appreciate it if I could get an ACK from one of you; if the > > former, my ACK is below. > > > > Acked-by: Paul Moore <paul@paul-moore.com> > > I'll merge this one into nf-next, this might simplify possible > conflict resolution later on. Yep, I think that's the best choice. Thanks. -- paul moore www.paul-moore.com ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v5] audit: log nftables configuration change events once per table 2021-03-26 17:38 ` Richard Guy Briggs @ 2021-03-31 20:22 ` Pablo Neira Ayuso -1 siblings, 0 replies; 22+ messages in thread From: Pablo Neira Ayuso @ 2021-03-31 20:22 UTC (permalink / raw) To: Richard Guy Briggs Cc: Jones Desougi, Phil Sutter, Florian Westphal, LKML, Linux-Audit Mailing List, netfilter-devel, twoerner, Eric Paris, tgraf, dan.carpenter [-- Attachment #1: Type: text/plain, Size: 442 bytes --] On Fri, Mar 26, 2021 at 01:38:59PM -0400, Richard Guy Briggs wrote: > Reduce logging of nftables events to a level similar to iptables. > Restore the table field to list the table, adding the generation. > > Indicate the op as the most significant operation in the event. There's a UAF, Florian reported. I'm attaching an incremental fix. nf_tables_commit_audit_collect() refers to the trans object which might have been already released. [-- Attachment #2: fix-uaf.patch --] [-- Type: text/x-diff, Size: 1079 bytes --] commit e4d272948d25b66d86fc241cefd95281bfb1079e Author: Pablo Neira Ayuso <pablo@netfilter.org> Date: Wed Mar 31 22:19:51 2021 +0200 netfilter: nf_tables: use-after-free Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c index 5dd4bb7cabf5..01674c0d9103 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -8063,6 +8063,8 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb) net->nft.gencursor = nft_gencursor_next(net); list_for_each_entry_safe(trans, next, &net->nft.commit_list, list) { + nf_tables_commit_audit_collect(&adl, trans->ctx.table, + trans->msg_type); switch (trans->msg_type) { case NFT_MSG_NEWTABLE: if (nft_trans_table_update(trans)) { @@ -8211,8 +8213,6 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb) } break; } - nf_tables_commit_audit_collect(&adl, trans->ctx.table, - trans->msg_type); } nft_commit_notify(net, NETLINK_CB(skb).portid); [-- Attachment #3: Type: text/plain, Size: 106 bytes --] -- Linux-audit mailing list Linux-audit@redhat.com https://listman.redhat.com/mailman/listinfo/linux-audit ^ permalink raw reply related [flat|nested] 22+ messages in thread
* Re: [PATCH v5] audit: log nftables configuration change events once per table @ 2021-03-31 20:22 ` Pablo Neira Ayuso 0 siblings, 0 replies; 22+ messages in thread From: Pablo Neira Ayuso @ 2021-03-31 20:22 UTC (permalink / raw) To: Richard Guy Briggs Cc: Linux-Audit Mailing List, LKML, netfilter-devel, Paul Moore, Eric Paris, Steve Grubb, Florian Westphal, Phil Sutter, twoerner, tgraf, dan.carpenter, Jones Desougi [-- Attachment #1: Type: text/plain, Size: 442 bytes --] On Fri, Mar 26, 2021 at 01:38:59PM -0400, Richard Guy Briggs wrote: > Reduce logging of nftables events to a level similar to iptables. > Restore the table field to list the table, adding the generation. > > Indicate the op as the most significant operation in the event. There's a UAF, Florian reported. I'm attaching an incremental fix. nf_tables_commit_audit_collect() refers to the trans object which might have been already released. [-- Attachment #2: fix-uaf.patch --] [-- Type: text/x-diff, Size: 1079 bytes --] commit e4d272948d25b66d86fc241cefd95281bfb1079e Author: Pablo Neira Ayuso <pablo@netfilter.org> Date: Wed Mar 31 22:19:51 2021 +0200 netfilter: nf_tables: use-after-free Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c index 5dd4bb7cabf5..01674c0d9103 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -8063,6 +8063,8 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb) net->nft.gencursor = nft_gencursor_next(net); list_for_each_entry_safe(trans, next, &net->nft.commit_list, list) { + nf_tables_commit_audit_collect(&adl, trans->ctx.table, + trans->msg_type); switch (trans->msg_type) { case NFT_MSG_NEWTABLE: if (nft_trans_table_update(trans)) { @@ -8211,8 +8213,6 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb) } break; } - nf_tables_commit_audit_collect(&adl, trans->ctx.table, - trans->msg_type); } nft_commit_notify(net, NETLINK_CB(skb).portid); ^ permalink raw reply related [flat|nested] 22+ messages in thread
* Re: [PATCH v5] audit: log nftables configuration change events once per table 2021-03-31 20:22 ` Pablo Neira Ayuso @ 2021-03-31 20:53 ` Richard Guy Briggs -1 siblings, 0 replies; 22+ messages in thread From: Richard Guy Briggs @ 2021-03-31 20:53 UTC (permalink / raw) To: Pablo Neira Ayuso Cc: Jones Desougi, Phil Sutter, Florian Westphal, LKML, Linux-Audit Mailing List, netfilter-devel, twoerner, Eric Paris, tgraf, dan.carpenter On 2021-03-31 22:22, Pablo Neira Ayuso wrote: > On Fri, Mar 26, 2021 at 01:38:59PM -0400, Richard Guy Briggs wrote: > > Reduce logging of nftables events to a level similar to iptables. > > Restore the table field to list the table, adding the generation. > > > > Indicate the op as the most significant operation in the event. > > There's a UAF, Florian reported. I'm attaching an incremental fix. > > nf_tables_commit_audit_collect() refers to the trans object which > might have been already released. Got it. Thanks Pablo. I didn't see it when running nft-test.py Where was it reported? Here I tried to stay out of the way by putting that call at the end of the loop but that was obviously a mistake in hindsight. :-) > commit e4d272948d25b66d86fc241cefd95281bfb1079e > Author: Pablo Neira Ayuso <pablo@netfilter.org> > Date: Wed Mar 31 22:19:51 2021 +0200 > > netfilter: nf_tables: use-after-free > > Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> > > diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c > index 5dd4bb7cabf5..01674c0d9103 100644 > --- a/net/netfilter/nf_tables_api.c > +++ b/net/netfilter/nf_tables_api.c > @@ -8063,6 +8063,8 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb) > net->nft.gencursor = nft_gencursor_next(net); > > list_for_each_entry_safe(trans, next, &net->nft.commit_list, list) { > + nf_tables_commit_audit_collect(&adl, trans->ctx.table, > + trans->msg_type); > switch (trans->msg_type) { > case NFT_MSG_NEWTABLE: > if (nft_trans_table_update(trans)) { > @@ -8211,8 +8213,6 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb) > } > break; > } > - nf_tables_commit_audit_collect(&adl, trans->ctx.table, > - trans->msg_type); > } > > nft_commit_notify(net, NETLINK_CB(skb).portid); - RGB -- Richard Guy Briggs <rgb@redhat.com> Sr. S/W Engineer, Kernel Security, Base Operating Systems Remote, Ottawa, Red Hat Canada IRC: rgb, SunRaycer Voice: +1.647.777.2635, Internal: (81) 32635 -- Linux-audit mailing list Linux-audit@redhat.com https://listman.redhat.com/mailman/listinfo/linux-audit ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v5] audit: log nftables configuration change events once per table @ 2021-03-31 20:53 ` Richard Guy Briggs 0 siblings, 0 replies; 22+ messages in thread From: Richard Guy Briggs @ 2021-03-31 20:53 UTC (permalink / raw) To: Pablo Neira Ayuso Cc: Linux-Audit Mailing List, LKML, netfilter-devel, Paul Moore, Eric Paris, Steve Grubb, Florian Westphal, Phil Sutter, twoerner, tgraf, dan.carpenter, Jones Desougi On 2021-03-31 22:22, Pablo Neira Ayuso wrote: > On Fri, Mar 26, 2021 at 01:38:59PM -0400, Richard Guy Briggs wrote: > > Reduce logging of nftables events to a level similar to iptables. > > Restore the table field to list the table, adding the generation. > > > > Indicate the op as the most significant operation in the event. > > There's a UAF, Florian reported. I'm attaching an incremental fix. > > nf_tables_commit_audit_collect() refers to the trans object which > might have been already released. Got it. Thanks Pablo. I didn't see it when running nft-test.py Where was it reported? Here I tried to stay out of the way by putting that call at the end of the loop but that was obviously a mistake in hindsight. :-) > commit e4d272948d25b66d86fc241cefd95281bfb1079e > Author: Pablo Neira Ayuso <pablo@netfilter.org> > Date: Wed Mar 31 22:19:51 2021 +0200 > > netfilter: nf_tables: use-after-free > > Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> > > diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c > index 5dd4bb7cabf5..01674c0d9103 100644 > --- a/net/netfilter/nf_tables_api.c > +++ b/net/netfilter/nf_tables_api.c > @@ -8063,6 +8063,8 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb) > net->nft.gencursor = nft_gencursor_next(net); > > list_for_each_entry_safe(trans, next, &net->nft.commit_list, list) { > + nf_tables_commit_audit_collect(&adl, trans->ctx.table, > + trans->msg_type); > switch (trans->msg_type) { > case NFT_MSG_NEWTABLE: > if (nft_trans_table_update(trans)) { > @@ -8211,8 +8213,6 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb) > } > break; > } > - nf_tables_commit_audit_collect(&adl, trans->ctx.table, > - trans->msg_type); > } > > nft_commit_notify(net, NETLINK_CB(skb).portid); - RGB -- Richard Guy Briggs <rgb@redhat.com> Sr. S/W Engineer, Kernel Security, Base Operating Systems Remote, Ottawa, Red Hat Canada IRC: rgb, SunRaycer Voice: +1.647.777.2635, Internal: (81) 32635 ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v5] audit: log nftables configuration change events once per table 2021-03-31 20:53 ` Richard Guy Briggs @ 2021-03-31 20:56 ` Pablo Neira Ayuso -1 siblings, 0 replies; 22+ messages in thread From: Pablo Neira Ayuso @ 2021-03-31 20:56 UTC (permalink / raw) To: Richard Guy Briggs Cc: Jones Desougi, Phil Sutter, Florian Westphal, LKML, Linux-Audit Mailing List, netfilter-devel, twoerner, Eric Paris, tgraf, dan.carpenter On Wed, Mar 31, 2021 at 04:53:10PM -0400, Richard Guy Briggs wrote: > On 2021-03-31 22:22, Pablo Neira Ayuso wrote: > > On Fri, Mar 26, 2021 at 01:38:59PM -0400, Richard Guy Briggs wrote: > > > Reduce logging of nftables events to a level similar to iptables. > > > Restore the table field to list the table, adding the generation. > > > > > > Indicate the op as the most significant operation in the event. > > > > There's a UAF, Florian reported. I'm attaching an incremental fix. > > > > nf_tables_commit_audit_collect() refers to the trans object which > > might have been already released. > > Got it. Thanks Pablo. I didn't see it when running nft-test.py Where > was it reported? CONFIG_KASAN. > Here I tried to stay out of the way by putting that > call at the end of the loop but that was obviously a mistake in > hindsight. :-) No problem, I'll squash this incremental fix into your audit patch. -- Linux-audit mailing list Linux-audit@redhat.com https://listman.redhat.com/mailman/listinfo/linux-audit ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v5] audit: log nftables configuration change events once per table @ 2021-03-31 20:56 ` Pablo Neira Ayuso 0 siblings, 0 replies; 22+ messages in thread From: Pablo Neira Ayuso @ 2021-03-31 20:56 UTC (permalink / raw) To: Richard Guy Briggs Cc: Linux-Audit Mailing List, LKML, netfilter-devel, Paul Moore, Eric Paris, Steve Grubb, Florian Westphal, Phil Sutter, twoerner, tgraf, dan.carpenter, Jones Desougi On Wed, Mar 31, 2021 at 04:53:10PM -0400, Richard Guy Briggs wrote: > On 2021-03-31 22:22, Pablo Neira Ayuso wrote: > > On Fri, Mar 26, 2021 at 01:38:59PM -0400, Richard Guy Briggs wrote: > > > Reduce logging of nftables events to a level similar to iptables. > > > Restore the table field to list the table, adding the generation. > > > > > > Indicate the op as the most significant operation in the event. > > > > There's a UAF, Florian reported. I'm attaching an incremental fix. > > > > nf_tables_commit_audit_collect() refers to the trans object which > > might have been already released. > > Got it. Thanks Pablo. I didn't see it when running nft-test.py Where > was it reported? CONFIG_KASAN. > Here I tried to stay out of the way by putting that > call at the end of the loop but that was obviously a mistake in > hindsight. :-) No problem, I'll squash this incremental fix into your audit patch. ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v5] audit: log nftables configuration change events once per table 2021-03-26 17:38 ` Richard Guy Briggs @ 2021-03-31 20:46 ` Pablo Neira Ayuso -1 siblings, 0 replies; 22+ messages in thread From: Pablo Neira Ayuso @ 2021-03-31 20:46 UTC (permalink / raw) To: Richard Guy Briggs Cc: Jones Desougi, Phil Sutter, Florian Westphal, LKML, Linux-Audit Mailing List, netfilter-devel, twoerner, Eric Paris, tgraf, dan.carpenter On Fri, Mar 26, 2021 at 01:38:59PM -0400, Richard Guy Briggs wrote: > @@ -8006,12 +7966,65 @@ static void nft_commit_notify(struct net *net, u32 portid) > WARN_ON_ONCE(!list_empty(&net->nft.notify_list)); > } > > +static int nf_tables_commit_audit_alloc(struct list_head *adl, > + struct nft_table *table) > +{ > + struct nft_audit_data *adp; > + > + list_for_each_entry(adp, adl, list) { > + if (adp->table == table) > + return 0; > + } > + adp = kzalloc(sizeof(*adp), GFP_KERNEL); > + if (!adp) > + return -ENOMEM; > + adp->table = table; > + INIT_LIST_HEAD(&adp->list); This INIT_LIST_HEAD is not required for an object that is going to be inserted into the 'adl' list. > + list_add(&adp->list, adl); If no objections, I'll amend this patch. I'll include the UAF fix and remove this unnecessary INIT_LIST_HEAD. -- Linux-audit mailing list Linux-audit@redhat.com https://listman.redhat.com/mailman/listinfo/linux-audit ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v5] audit: log nftables configuration change events once per table @ 2021-03-31 20:46 ` Pablo Neira Ayuso 0 siblings, 0 replies; 22+ messages in thread From: Pablo Neira Ayuso @ 2021-03-31 20:46 UTC (permalink / raw) To: Richard Guy Briggs Cc: Linux-Audit Mailing List, LKML, netfilter-devel, Paul Moore, Eric Paris, Steve Grubb, Florian Westphal, Phil Sutter, twoerner, tgraf, dan.carpenter, Jones Desougi On Fri, Mar 26, 2021 at 01:38:59PM -0400, Richard Guy Briggs wrote: > @@ -8006,12 +7966,65 @@ static void nft_commit_notify(struct net *net, u32 portid) > WARN_ON_ONCE(!list_empty(&net->nft.notify_list)); > } > > +static int nf_tables_commit_audit_alloc(struct list_head *adl, > + struct nft_table *table) > +{ > + struct nft_audit_data *adp; > + > + list_for_each_entry(adp, adl, list) { > + if (adp->table == table) > + return 0; > + } > + adp = kzalloc(sizeof(*adp), GFP_KERNEL); > + if (!adp) > + return -ENOMEM; > + adp->table = table; > + INIT_LIST_HEAD(&adp->list); This INIT_LIST_HEAD is not required for an object that is going to be inserted into the 'adl' list. > + list_add(&adp->list, adl); If no objections, I'll amend this patch. I'll include the UAF fix and remove this unnecessary INIT_LIST_HEAD. ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v5] audit: log nftables configuration change events once per table 2021-03-31 20:46 ` Pablo Neira Ayuso @ 2021-03-31 20:55 ` Richard Guy Briggs -1 siblings, 0 replies; 22+ messages in thread From: Richard Guy Briggs @ 2021-03-31 20:55 UTC (permalink / raw) To: Pablo Neira Ayuso Cc: Jones Desougi, Phil Sutter, Florian Westphal, LKML, Linux-Audit Mailing List, netfilter-devel, twoerner, Eric Paris, tgraf, dan.carpenter On 2021-03-31 22:46, Pablo Neira Ayuso wrote: > On Fri, Mar 26, 2021 at 01:38:59PM -0400, Richard Guy Briggs wrote: > > @@ -8006,12 +7966,65 @@ static void nft_commit_notify(struct net *net, u32 portid) > > WARN_ON_ONCE(!list_empty(&net->nft.notify_list)); > > } > > > > +static int nf_tables_commit_audit_alloc(struct list_head *adl, > > + struct nft_table *table) > > +{ > > + struct nft_audit_data *adp; > > + > > + list_for_each_entry(adp, adl, list) { > > + if (adp->table == table) > > + return 0; > > + } > > + adp = kzalloc(sizeof(*adp), GFP_KERNEL); > > + if (!adp) > > + return -ENOMEM; > > + adp->table = table; > > + INIT_LIST_HEAD(&adp->list); > > This INIT_LIST_HEAD is not required for an object that is going to be > inserted into the 'adl' list. > > > + list_add(&adp->list, adl); > > If no objections, I'll amend this patch. I'll include the UAF fix and > remove this unnecessary INIT_LIST_HEAD. Ok, so it is harmless other than being code noise and overhead, thanks again. - RGB -- Richard Guy Briggs <rgb@redhat.com> Sr. S/W Engineer, Kernel Security, Base Operating Systems Remote, Ottawa, Red Hat Canada IRC: rgb, SunRaycer Voice: +1.647.777.2635, Internal: (81) 32635 -- Linux-audit mailing list Linux-audit@redhat.com https://listman.redhat.com/mailman/listinfo/linux-audit ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v5] audit: log nftables configuration change events once per table @ 2021-03-31 20:55 ` Richard Guy Briggs 0 siblings, 0 replies; 22+ messages in thread From: Richard Guy Briggs @ 2021-03-31 20:55 UTC (permalink / raw) To: Pablo Neira Ayuso Cc: Linux-Audit Mailing List, LKML, netfilter-devel, Paul Moore, Eric Paris, Steve Grubb, Florian Westphal, Phil Sutter, twoerner, tgraf, dan.carpenter, Jones Desougi On 2021-03-31 22:46, Pablo Neira Ayuso wrote: > On Fri, Mar 26, 2021 at 01:38:59PM -0400, Richard Guy Briggs wrote: > > @@ -8006,12 +7966,65 @@ static void nft_commit_notify(struct net *net, u32 portid) > > WARN_ON_ONCE(!list_empty(&net->nft.notify_list)); > > } > > > > +static int nf_tables_commit_audit_alloc(struct list_head *adl, > > + struct nft_table *table) > > +{ > > + struct nft_audit_data *adp; > > + > > + list_for_each_entry(adp, adl, list) { > > + if (adp->table == table) > > + return 0; > > + } > > + adp = kzalloc(sizeof(*adp), GFP_KERNEL); > > + if (!adp) > > + return -ENOMEM; > > + adp->table = table; > > + INIT_LIST_HEAD(&adp->list); > > This INIT_LIST_HEAD is not required for an object that is going to be > inserted into the 'adl' list. > > > + list_add(&adp->list, adl); > > If no objections, I'll amend this patch. I'll include the UAF fix and > remove this unnecessary INIT_LIST_HEAD. Ok, so it is harmless other than being code noise and overhead, thanks again. - RGB -- Richard Guy Briggs <rgb@redhat.com> Sr. S/W Engineer, Kernel Security, Base Operating Systems Remote, Ottawa, Red Hat Canada IRC: rgb, SunRaycer Voice: +1.647.777.2635, Internal: (81) 32635 ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v5] audit: log nftables configuration change events once per table 2021-03-26 17:38 ` Richard Guy Briggs @ 2021-04-01 13:24 ` Phil Sutter -1 siblings, 0 replies; 22+ messages in thread From: Phil Sutter @ 2021-04-01 13:24 UTC (permalink / raw) To: Richard Guy Briggs Cc: Jones Desougi, Florian Westphal, LKML, Linux-Audit Mailing List, netfilter-devel, twoerner, Eric Paris, tgraf, dan.carpenter On Fri, Mar 26, 2021 at 01:38:59PM -0400, Richard Guy Briggs wrote: > Reduce logging of nftables events to a level similar to iptables. > Restore the table field to list the table, adding the generation. > > Indicate the op as the most significant operation in the event. > > A couple of sample events: > > type=PROCTITLE msg=audit(2021-03-18 09:30:49.801:143) : proctitle=/usr/bin/python3 -s /usr/sbin/firewalld --nofork --nopid > type=SYSCALL msg=audit(2021-03-18 09:30:49.801:143) : arch=x86_64 syscall=sendmsg success=yes exit=172 a0=0x6 a1=0x7ffdcfcbe650 a2=0x0 a3=0x7ffdcfcbd52c items=0 ppid=1 pid=367 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=roo > t sgid=root fsgid=root tty=(none) ses=unset comm=firewalld exe=/usr/bin/python3.9 subj=system_u:system_r:firewalld_t:s0 key=(null) > type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.801:143) : table=firewalld:2 family=ipv6 entries=1 op=nft_register_table pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld > type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.801:143) : table=firewalld:2 family=ipv4 entries=1 op=nft_register_table pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld > type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.801:143) : table=firewalld:2 family=inet entries=1 op=nft_register_table pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld > > type=PROCTITLE msg=audit(2021-03-18 09:30:49.839:144) : proctitle=/usr/bin/python3 -s /usr/sbin/firewalld --nofork --nopid > type=SYSCALL msg=audit(2021-03-18 09:30:49.839:144) : arch=x86_64 syscall=sendmsg success=yes exit=22792 a0=0x6 a1=0x7ffdcfcbe650 a2=0x0 a3=0x7ffdcfcbd52c items=0 ppid=1 pid=367 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=r > oot sgid=root fsgid=root tty=(none) ses=unset comm=firewalld exe=/usr/bin/python3.9 subj=system_u:system_r:firewalld_t:s0 key=(null) > type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.839:144) : table=firewalld:3 family=ipv6 entries=30 op=nft_register_chain pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld > type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.839:144) : table=firewalld:3 family=ipv4 entries=30 op=nft_register_chain pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld > type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.839:144) : table=firewalld:3 family=inet entries=165 op=nft_register_chain pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld > > The issue was originally documented in > https://github.com/linux-audit/audit-kernel/issues/124 > > Signed-off-by: Richard Guy Briggs <rgb@redhat.com> Tested this patch to make sure it eliminates the slowdown of iptables-nft when auditd is running. With this applied, neither iptables-nft-restore nor 'iptables-nft -F' show a significant difference in run-time between running or stopped auditd, at least for large rulesets. Individual calls suffer from added audit logging, but that's expected of course. Tested-by: Phil Sutter <phil@nwl.cc> Thanks, Phil -- Linux-audit mailing list Linux-audit@redhat.com https://listman.redhat.com/mailman/listinfo/linux-audit ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v5] audit: log nftables configuration change events once per table @ 2021-04-01 13:24 ` Phil Sutter 0 siblings, 0 replies; 22+ messages in thread From: Phil Sutter @ 2021-04-01 13:24 UTC (permalink / raw) To: Richard Guy Briggs Cc: Linux-Audit Mailing List, LKML, netfilter-devel, Paul Moore, Eric Paris, Steve Grubb, Florian Westphal, twoerner, tgraf, dan.carpenter, Jones Desougi On Fri, Mar 26, 2021 at 01:38:59PM -0400, Richard Guy Briggs wrote: > Reduce logging of nftables events to a level similar to iptables. > Restore the table field to list the table, adding the generation. > > Indicate the op as the most significant operation in the event. > > A couple of sample events: > > type=PROCTITLE msg=audit(2021-03-18 09:30:49.801:143) : proctitle=/usr/bin/python3 -s /usr/sbin/firewalld --nofork --nopid > type=SYSCALL msg=audit(2021-03-18 09:30:49.801:143) : arch=x86_64 syscall=sendmsg success=yes exit=172 a0=0x6 a1=0x7ffdcfcbe650 a2=0x0 a3=0x7ffdcfcbd52c items=0 ppid=1 pid=367 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=roo > t sgid=root fsgid=root tty=(none) ses=unset comm=firewalld exe=/usr/bin/python3.9 subj=system_u:system_r:firewalld_t:s0 key=(null) > type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.801:143) : table=firewalld:2 family=ipv6 entries=1 op=nft_register_table pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld > type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.801:143) : table=firewalld:2 family=ipv4 entries=1 op=nft_register_table pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld > type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.801:143) : table=firewalld:2 family=inet entries=1 op=nft_register_table pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld > > type=PROCTITLE msg=audit(2021-03-18 09:30:49.839:144) : proctitle=/usr/bin/python3 -s /usr/sbin/firewalld --nofork --nopid > type=SYSCALL msg=audit(2021-03-18 09:30:49.839:144) : arch=x86_64 syscall=sendmsg success=yes exit=22792 a0=0x6 a1=0x7ffdcfcbe650 a2=0x0 a3=0x7ffdcfcbd52c items=0 ppid=1 pid=367 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=r > oot sgid=root fsgid=root tty=(none) ses=unset comm=firewalld exe=/usr/bin/python3.9 subj=system_u:system_r:firewalld_t:s0 key=(null) > type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.839:144) : table=firewalld:3 family=ipv6 entries=30 op=nft_register_chain pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld > type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.839:144) : table=firewalld:3 family=ipv4 entries=30 op=nft_register_chain pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld > type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.839:144) : table=firewalld:3 family=inet entries=165 op=nft_register_chain pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld > > The issue was originally documented in > https://github.com/linux-audit/audit-kernel/issues/124 > > Signed-off-by: Richard Guy Briggs <rgb@redhat.com> Tested this patch to make sure it eliminates the slowdown of iptables-nft when auditd is running. With this applied, neither iptables-nft-restore nor 'iptables-nft -F' show a significant difference in run-time between running or stopped auditd, at least for large rulesets. Individual calls suffer from added audit logging, but that's expected of course. Tested-by: Phil Sutter <phil@nwl.cc> Thanks, Phil ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v5] audit: log nftables configuration change events once per table 2021-04-01 13:24 ` Phil Sutter @ 2021-04-01 13:34 ` Richard Guy Briggs -1 siblings, 0 replies; 22+ messages in thread From: Richard Guy Briggs @ 2021-04-01 13:34 UTC (permalink / raw) To: Phil Sutter, Linux-Audit Mailing List, LKML, netfilter-devel, Paul Moore, Eric Paris, Steve Grubb, Florian Westphal, twoerner, tgraf, dan.carpenter, Jones Desougi On 2021-04-01 15:24, Phil Sutter wrote: > On Fri, Mar 26, 2021 at 01:38:59PM -0400, Richard Guy Briggs wrote: > > Reduce logging of nftables events to a level similar to iptables. > > Restore the table field to list the table, adding the generation. > > > > Indicate the op as the most significant operation in the event. > > > > A couple of sample events: > > > > type=PROCTITLE msg=audit(2021-03-18 09:30:49.801:143) : proctitle=/usr/bin/python3 -s /usr/sbin/firewalld --nofork --nopid > > type=SYSCALL msg=audit(2021-03-18 09:30:49.801:143) : arch=x86_64 syscall=sendmsg success=yes exit=172 a0=0x6 a1=0x7ffdcfcbe650 a2=0x0 a3=0x7ffdcfcbd52c items=0 ppid=1 pid=367 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=roo > > t sgid=root fsgid=root tty=(none) ses=unset comm=firewalld exe=/usr/bin/python3.9 subj=system_u:system_r:firewalld_t:s0 key=(null) > > type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.801:143) : table=firewalld:2 family=ipv6 entries=1 op=nft_register_table pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld > > type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.801:143) : table=firewalld:2 family=ipv4 entries=1 op=nft_register_table pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld > > type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.801:143) : table=firewalld:2 family=inet entries=1 op=nft_register_table pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld > > > > type=PROCTITLE msg=audit(2021-03-18 09:30:49.839:144) : proctitle=/usr/bin/python3 -s /usr/sbin/firewalld --nofork --nopid > > type=SYSCALL msg=audit(2021-03-18 09:30:49.839:144) : arch=x86_64 syscall=sendmsg success=yes exit=22792 a0=0x6 a1=0x7ffdcfcbe650 a2=0x0 a3=0x7ffdcfcbd52c items=0 ppid=1 pid=367 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=r > > oot sgid=root fsgid=root tty=(none) ses=unset comm=firewalld exe=/usr/bin/python3.9 subj=system_u:system_r:firewalld_t:s0 key=(null) > > type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.839:144) : table=firewalld:3 family=ipv6 entries=30 op=nft_register_chain pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld > > type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.839:144) : table=firewalld:3 family=ipv4 entries=30 op=nft_register_chain pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld > > type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.839:144) : table=firewalld:3 family=inet entries=165 op=nft_register_chain pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld > > > > The issue was originally documented in > > https://github.com/linux-audit/audit-kernel/issues/124 > > > > Signed-off-by: Richard Guy Briggs <rgb@redhat.com> > > Tested this patch to make sure it eliminates the slowdown of > iptables-nft when auditd is running. With this applied, neither > iptables-nft-restore nor 'iptables-nft -F' show a significant > difference in run-time between running or stopped auditd, at least for > large rulesets. Individual calls suffer from added audit logging, but > that's expected of course. > > Tested-by: Phil Sutter <phil@nwl.cc> Excellent, thanks Phil for helping nail this one down and confirming the fix. > Thanks, Phil - RGB -- Richard Guy Briggs <rgb@redhat.com> Sr. S/W Engineer, Kernel Security, Base Operating Systems Remote, Ottawa, Red Hat Canada IRC: rgb, SunRaycer Voice: +1.647.777.2635, Internal: (81) 32635 -- Linux-audit mailing list Linux-audit@redhat.com https://listman.redhat.com/mailman/listinfo/linux-audit ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v5] audit: log nftables configuration change events once per table @ 2021-04-01 13:34 ` Richard Guy Briggs 0 siblings, 0 replies; 22+ messages in thread From: Richard Guy Briggs @ 2021-04-01 13:34 UTC (permalink / raw) To: Phil Sutter, Linux-Audit Mailing List, LKML, netfilter-devel, Paul Moore, Eric Paris, Steve Grubb, Florian Westphal, twoerner, tgraf, dan.carpenter, Jones Desougi On 2021-04-01 15:24, Phil Sutter wrote: > On Fri, Mar 26, 2021 at 01:38:59PM -0400, Richard Guy Briggs wrote: > > Reduce logging of nftables events to a level similar to iptables. > > Restore the table field to list the table, adding the generation. > > > > Indicate the op as the most significant operation in the event. > > > > A couple of sample events: > > > > type=PROCTITLE msg=audit(2021-03-18 09:30:49.801:143) : proctitle=/usr/bin/python3 -s /usr/sbin/firewalld --nofork --nopid > > type=SYSCALL msg=audit(2021-03-18 09:30:49.801:143) : arch=x86_64 syscall=sendmsg success=yes exit=172 a0=0x6 a1=0x7ffdcfcbe650 a2=0x0 a3=0x7ffdcfcbd52c items=0 ppid=1 pid=367 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=roo > > t sgid=root fsgid=root tty=(none) ses=unset comm=firewalld exe=/usr/bin/python3.9 subj=system_u:system_r:firewalld_t:s0 key=(null) > > type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.801:143) : table=firewalld:2 family=ipv6 entries=1 op=nft_register_table pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld > > type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.801:143) : table=firewalld:2 family=ipv4 entries=1 op=nft_register_table pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld > > type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.801:143) : table=firewalld:2 family=inet entries=1 op=nft_register_table pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld > > > > type=PROCTITLE msg=audit(2021-03-18 09:30:49.839:144) : proctitle=/usr/bin/python3 -s /usr/sbin/firewalld --nofork --nopid > > type=SYSCALL msg=audit(2021-03-18 09:30:49.839:144) : arch=x86_64 syscall=sendmsg success=yes exit=22792 a0=0x6 a1=0x7ffdcfcbe650 a2=0x0 a3=0x7ffdcfcbd52c items=0 ppid=1 pid=367 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=r > > oot sgid=root fsgid=root tty=(none) ses=unset comm=firewalld exe=/usr/bin/python3.9 subj=system_u:system_r:firewalld_t:s0 key=(null) > > type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.839:144) : table=firewalld:3 family=ipv6 entries=30 op=nft_register_chain pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld > > type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.839:144) : table=firewalld:3 family=ipv4 entries=30 op=nft_register_chain pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld > > type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.839:144) : table=firewalld:3 family=inet entries=165 op=nft_register_chain pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld > > > > The issue was originally documented in > > https://github.com/linux-audit/audit-kernel/issues/124 > > > > Signed-off-by: Richard Guy Briggs <rgb@redhat.com> > > Tested this patch to make sure it eliminates the slowdown of > iptables-nft when auditd is running. With this applied, neither > iptables-nft-restore nor 'iptables-nft -F' show a significant > difference in run-time between running or stopped auditd, at least for > large rulesets. Individual calls suffer from added audit logging, but > that's expected of course. > > Tested-by: Phil Sutter <phil@nwl.cc> Excellent, thanks Phil for helping nail this one down and confirming the fix. > Thanks, Phil - RGB -- Richard Guy Briggs <rgb@redhat.com> Sr. S/W Engineer, Kernel Security, Base Operating Systems Remote, Ottawa, Red Hat Canada IRC: rgb, SunRaycer Voice: +1.647.777.2635, Internal: (81) 32635 ^ permalink raw reply [flat|nested] 22+ messages in thread
end of thread, other threads:[~2021-04-01 17:47 UTC | newest] Thread overview: 22+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2021-03-26 17:38 [PATCH v5] audit: log nftables configuration change events once per table Richard Guy Briggs 2021-03-26 17:38 ` Richard Guy Briggs 2021-03-29 0:50 ` Paul Moore 2021-03-29 0:50 ` Paul Moore 2021-03-30 22:53 ` Pablo Neira Ayuso 2021-03-30 22:53 ` Pablo Neira Ayuso 2021-03-31 0:50 ` Paul Moore 2021-03-31 0:50 ` Paul Moore 2021-03-31 20:22 ` Pablo Neira Ayuso 2021-03-31 20:22 ` Pablo Neira Ayuso 2021-03-31 20:53 ` Richard Guy Briggs 2021-03-31 20:53 ` Richard Guy Briggs 2021-03-31 20:56 ` Pablo Neira Ayuso 2021-03-31 20:56 ` Pablo Neira Ayuso 2021-03-31 20:46 ` Pablo Neira Ayuso 2021-03-31 20:46 ` Pablo Neira Ayuso 2021-03-31 20:55 ` Richard Guy Briggs 2021-03-31 20:55 ` Richard Guy Briggs 2021-04-01 13:24 ` Phil Sutter 2021-04-01 13:24 ` Phil Sutter 2021-04-01 13:34 ` Richard Guy Briggs 2021-04-01 13:34 ` Richard Guy Briggs
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.