All of lore.kernel.org
 help / color / mirror / Atom feed
From: Phil Sutter <phil@nwl.cc>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: Richard Guy Briggs <rgb@redhat.com>,
	linux-audit@redhat.com, netfilter-devel@vger.kernel.org
Subject: Re: [nf PATCH 1/2] netfilter: nf_tables: Audit log setelem reset
Date: Tue, 29 Aug 2023 20:38:48 +0200	[thread overview]
Message-ID: <ZO47OErdLysNiMsA@orbyte.nwl.cc> (raw)
In-Reply-To: <ZO4ytkCaWgprr4ba@calendula>

On Tue, Aug 29, 2023 at 08:02:30PM +0200, Pablo Neira Ayuso wrote:
> On Tue, Aug 29, 2023 at 07:51:57PM +0200, Phil Sutter wrote:
> > Since set element reset is not integrated into nf_tables' transaction
> > logic, an explicit log call is needed, similar to NFT_MSG_GETOBJ_RESET
> > handling.
> > 
> > For the sake of simplicity, catchall element reset will always generate
> > a dedicated log entry. This relieves nf_tables_dump_set() from having to
> > adjust the logged element count depending on whether a catchall element
> > was found or not.
> > 
> > Cc: Richard Guy Briggs <rgb@redhat.com>
> > Fixes: 079cd633219d7 ("netfilter: nf_tables: Introduce NFT_MSG_GETSETELEM_RESET")
> > Signed-off-by: Phil Sutter <phil@nwl.cc>
> > ---
> >  include/linux/audit.h         |  1 +
> >  kernel/auditsc.c              |  1 +
> >  net/netfilter/nf_tables_api.c | 31 ++++++++++++++++++++++++++++---
> >  3 files changed, 30 insertions(+), 3 deletions(-)
> > 
> > diff --git a/include/linux/audit.h b/include/linux/audit.h
> > index 6a3a9e122bb5e..192bf03aacc52 100644
> > --- a/include/linux/audit.h
> > +++ b/include/linux/audit.h
> > @@ -117,6 +117,7 @@ enum audit_nfcfgop {
> >  	AUDIT_NFT_OP_OBJ_RESET,
> >  	AUDIT_NFT_OP_FLOWTABLE_REGISTER,
> >  	AUDIT_NFT_OP_FLOWTABLE_UNREGISTER,
> > +	AUDIT_NFT_OP_SETELEM_RESET,
> >  	AUDIT_NFT_OP_INVALID,
> >  };
> >  
> > diff --git a/kernel/auditsc.c b/kernel/auditsc.c
> > index addeed3df15d3..38481e3181975 100644
> > --- a/kernel/auditsc.c
> > +++ b/kernel/auditsc.c
> > @@ -143,6 +143,7 @@ static const struct audit_nfcfgop_tab audit_nfcfgs[] = {
> >  	{ AUDIT_NFT_OP_OBJ_RESET,		"nft_reset_obj"		   },
> >  	{ AUDIT_NFT_OP_FLOWTABLE_REGISTER,	"nft_register_flowtable"   },
> >  	{ AUDIT_NFT_OP_FLOWTABLE_UNREGISTER,	"nft_unregister_flowtable" },
> > +	{ AUDIT_NFT_OP_SETELEM_RESET,		"nft_reset_setelem"        },
> >  	{ AUDIT_NFT_OP_INVALID,			"nft_invalid"		   },
> >  };
> >  
> > diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
> > index 1ddbdca4e47d6..a1218ea4e0c3d 100644
> > --- a/net/netfilter/nf_tables_api.c
> > +++ b/net/netfilter/nf_tables_api.c
> > @@ -102,6 +102,7 @@ static const u8 nft2audit_op[NFT_MSG_MAX] = { // enum nf_tables_msg_types
> >  	[NFT_MSG_NEWFLOWTABLE]	= AUDIT_NFT_OP_FLOWTABLE_REGISTER,
> >  	[NFT_MSG_GETFLOWTABLE]	= AUDIT_NFT_OP_INVALID,
> >  	[NFT_MSG_DELFLOWTABLE]	= AUDIT_NFT_OP_FLOWTABLE_UNREGISTER,
> > +	[NFT_MSG_GETSETELEM_RESET] = AUDIT_NFT_OP_SETELEM_RESET,
> >  };
> >  
> >  static void nft_validate_state_update(struct nft_table *table, u8 new_validate_state)
> > @@ -5661,13 +5662,25 @@ static int nf_tables_dump_setelem(const struct nft_ctx *ctx,
> >  	return nf_tables_fill_setelem(args->skb, set, elem, args->reset);
> >  }
> >  
> > +static void audit_log_nft_set_reset(const struct nft_table *table,
> > +				    unsigned int base_seq,
> > +				    unsigned int nentries)
> > +{
> > +	char *buf = kasprintf(GFP_ATOMIC, "%s:%u", table->name, base_seq);
> 
> No check for NULL?
> 
> I can see we have more like this in the tree.

Well, I merely copy-pasted that bit. (No excuse, I know.) The pointer is
passed on to audit_log_format() as a string argument and will end at
vsnprintf(), which detects and sanitizes NULL string args.

Cheers, Phil


--
Linux-audit mailing list
Linux-audit@redhat.com
https://listman.redhat.com/mailman/listinfo/linux-audit


WARNING: multiple messages have this Message-ID (diff)
From: Phil Sutter <phil@nwl.cc>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: netfilter-devel@vger.kernel.org, linux-audit@redhat.com,
	Richard Guy Briggs <rgb@redhat.com>
Subject: Re: [nf PATCH 1/2] netfilter: nf_tables: Audit log setelem reset
Date: Tue, 29 Aug 2023 20:38:48 +0200	[thread overview]
Message-ID: <ZO47OErdLysNiMsA@orbyte.nwl.cc> (raw)
In-Reply-To: <ZO4ytkCaWgprr4ba@calendula>

On Tue, Aug 29, 2023 at 08:02:30PM +0200, Pablo Neira Ayuso wrote:
> On Tue, Aug 29, 2023 at 07:51:57PM +0200, Phil Sutter wrote:
> > Since set element reset is not integrated into nf_tables' transaction
> > logic, an explicit log call is needed, similar to NFT_MSG_GETOBJ_RESET
> > handling.
> > 
> > For the sake of simplicity, catchall element reset will always generate
> > a dedicated log entry. This relieves nf_tables_dump_set() from having to
> > adjust the logged element count depending on whether a catchall element
> > was found or not.
> > 
> > Cc: Richard Guy Briggs <rgb@redhat.com>
> > Fixes: 079cd633219d7 ("netfilter: nf_tables: Introduce NFT_MSG_GETSETELEM_RESET")
> > Signed-off-by: Phil Sutter <phil@nwl.cc>
> > ---
> >  include/linux/audit.h         |  1 +
> >  kernel/auditsc.c              |  1 +
> >  net/netfilter/nf_tables_api.c | 31 ++++++++++++++++++++++++++++---
> >  3 files changed, 30 insertions(+), 3 deletions(-)
> > 
> > diff --git a/include/linux/audit.h b/include/linux/audit.h
> > index 6a3a9e122bb5e..192bf03aacc52 100644
> > --- a/include/linux/audit.h
> > +++ b/include/linux/audit.h
> > @@ -117,6 +117,7 @@ enum audit_nfcfgop {
> >  	AUDIT_NFT_OP_OBJ_RESET,
> >  	AUDIT_NFT_OP_FLOWTABLE_REGISTER,
> >  	AUDIT_NFT_OP_FLOWTABLE_UNREGISTER,
> > +	AUDIT_NFT_OP_SETELEM_RESET,
> >  	AUDIT_NFT_OP_INVALID,
> >  };
> >  
> > diff --git a/kernel/auditsc.c b/kernel/auditsc.c
> > index addeed3df15d3..38481e3181975 100644
> > --- a/kernel/auditsc.c
> > +++ b/kernel/auditsc.c
> > @@ -143,6 +143,7 @@ static const struct audit_nfcfgop_tab audit_nfcfgs[] = {
> >  	{ AUDIT_NFT_OP_OBJ_RESET,		"nft_reset_obj"		   },
> >  	{ AUDIT_NFT_OP_FLOWTABLE_REGISTER,	"nft_register_flowtable"   },
> >  	{ AUDIT_NFT_OP_FLOWTABLE_UNREGISTER,	"nft_unregister_flowtable" },
> > +	{ AUDIT_NFT_OP_SETELEM_RESET,		"nft_reset_setelem"        },
> >  	{ AUDIT_NFT_OP_INVALID,			"nft_invalid"		   },
> >  };
> >  
> > diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
> > index 1ddbdca4e47d6..a1218ea4e0c3d 100644
> > --- a/net/netfilter/nf_tables_api.c
> > +++ b/net/netfilter/nf_tables_api.c
> > @@ -102,6 +102,7 @@ static const u8 nft2audit_op[NFT_MSG_MAX] = { // enum nf_tables_msg_types
> >  	[NFT_MSG_NEWFLOWTABLE]	= AUDIT_NFT_OP_FLOWTABLE_REGISTER,
> >  	[NFT_MSG_GETFLOWTABLE]	= AUDIT_NFT_OP_INVALID,
> >  	[NFT_MSG_DELFLOWTABLE]	= AUDIT_NFT_OP_FLOWTABLE_UNREGISTER,
> > +	[NFT_MSG_GETSETELEM_RESET] = AUDIT_NFT_OP_SETELEM_RESET,
> >  };
> >  
> >  static void nft_validate_state_update(struct nft_table *table, u8 new_validate_state)
> > @@ -5661,13 +5662,25 @@ static int nf_tables_dump_setelem(const struct nft_ctx *ctx,
> >  	return nf_tables_fill_setelem(args->skb, set, elem, args->reset);
> >  }
> >  
> > +static void audit_log_nft_set_reset(const struct nft_table *table,
> > +				    unsigned int base_seq,
> > +				    unsigned int nentries)
> > +{
> > +	char *buf = kasprintf(GFP_ATOMIC, "%s:%u", table->name, base_seq);
> 
> No check for NULL?
> 
> I can see we have more like this in the tree.

Well, I merely copy-pasted that bit. (No excuse, I know.) The pointer is
passed on to audit_log_format() as a string argument and will end at
vsnprintf(), which detects and sanitizes NULL string args.

Cheers, Phil



  reply	other threads:[~2023-08-29 19:11 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-29 17:51 [nf PATCH 1/2] netfilter: nf_tables: Audit log setelem reset Phil Sutter
2023-08-29 17:51 ` Phil Sutter
2023-08-29 17:51 ` [nf PATCH 2/2] netfilter: nf_tables: Audit log rule reset Phil Sutter
2023-08-29 17:51   ` Phil Sutter
2023-08-29 18:02   ` Pablo Neira Ayuso
2023-08-29 18:02     ` Pablo Neira Ayuso
2023-08-30 15:47   ` Pablo Neira Ayuso
2023-08-30 15:47     ` Pablo Neira Ayuso
2023-08-31  2:27   ` Paul Moore
2023-08-31  2:27     ` Paul Moore
2023-08-29 18:02 ` [nf PATCH 1/2] netfilter: nf_tables: Audit log setelem reset Pablo Neira Ayuso
2023-08-29 18:02   ` Pablo Neira Ayuso
2023-08-29 18:38   ` Phil Sutter [this message]
2023-08-29 18:38     ` Phil Sutter
2023-08-30 15:46 ` Pablo Neira Ayuso
2023-08-30 15:46   ` Pablo Neira Ayuso
2023-08-30 20:54   ` Richard Guy Briggs
2023-08-30 20:54     ` Richard Guy Briggs
2023-08-31  2:26     ` Paul Moore
2023-08-31  2:26       ` Paul Moore

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZO47OErdLysNiMsA@orbyte.nwl.cc \
    --to=phil@nwl.cc \
    --cc=linux-audit@redhat.com \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    --cc=rgb@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.