Linux-audit Archive on lore.kernel.org
 help / color / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Richard Guy Briggs <rgb@redhat.com>
Cc: Jones Desougi <jones.desougi+netfilter@gmail.com>,
	Phil Sutter <phil@nwl.cc>, Florian Westphal <fw@strlen.de>,
	LKML <linux-kernel@vger.kernel.org>,
	Linux-Audit Mailing List <linux-audit@redhat.com>,
	netfilter-devel@vger.kernel.org, twoerner@redhat.com,
	Eric Paris <eparis@parisplace.org>,
	tgraf@infradead.org, dan.carpenter@oracle.com
Subject: Re: [PATCH v5] audit: log nftables configuration change events once per table
Date: Wed, 31 Mar 2021 22:22:30 +0200
Message-ID: <20210331202230.GA4109@salvia> (raw)
In-Reply-To: <28de34275f58b45fd4626a92ccae96b6d2b4e287.1616702731.git.rgb@redhat.com>


[-- 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

  parent reply index

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-26 17:38 Richard Guy Briggs
2021-03-29  0:50 ` Paul Moore
2021-03-30 22:53   ` Pablo Neira Ayuso
2021-03-31  0:50     ` Paul Moore
2021-03-31 20:22 ` Pablo Neira Ayuso [this message]
2021-03-31 20:53   ` Richard Guy Briggs
2021-03-31 20:56     ` Pablo Neira Ayuso
2021-03-31 20:46 ` Pablo Neira Ayuso
2021-03-31 20:55   ` Richard Guy Briggs
2021-04-01 13:24 ` Phil Sutter
2021-04-01 13:34   ` Richard Guy Briggs

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=20210331202230.GA4109@salvia \
    --to=pablo@netfilter.org \
    --cc=dan.carpenter@oracle.com \
    --cc=eparis@parisplace.org \
    --cc=fw@strlen.de \
    --cc=jones.desougi+netfilter@gmail.com \
    --cc=linux-audit@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=phil@nwl.cc \
    --cc=rgb@redhat.com \
    --cc=tgraf@infradead.org \
    --cc=twoerner@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

Linux-audit Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-audit/0 linux-audit/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-audit linux-audit/ https://lore.kernel.org/linux-audit \
		linux-audit@redhat.com
	public-inbox-index linux-audit

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/com.redhat.linux-audit


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git