mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hillf Danton <hdanton@sina.com>
To: syzbot <syzbot+4fd66a69358fc15ae2ad@syzkaller.appspotmail.com>
Cc: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] [netfilter?] KASAN: slab-use-after-free Read in nf_tables_trans_destroy_work
Date: Tue,  2 Jul 2024 19:28:14 +0800	[thread overview]
Message-ID: <20240702112814.2760-1-hdanton@sina.com> (raw)
In-Reply-To: <000000000000aa1dbb061c354fe6@google.com>

On Mon, 01 Jul 2024 13:19:15 -0700
> syzbot found the following issue on:
> 
> HEAD commit:    1c5fc27bc48a Merge tag 'nf-next-24-06-28' of git://git.ker..
> git tree:       net-next
> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=12cecb1e980000

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git  1c5fc27bc48a

--- x/include/net/netfilter/nf_tables.h
+++ y/include/net/netfilter/nf_tables.h
@@ -1281,6 +1281,7 @@ struct nft_table {
 	u64				hgenerator;
 	u64				handle;
 	u32				use;
+	atomic_t			cnt;
 	u16				family:6,
 					flags:8,
 					genmask:2;
--- x/net/netfilter/nf_tables_api.c
+++ y/net/netfilter/nf_tables_api.c
@@ -162,6 +162,8 @@ static struct nft_trans *nft_trans_alloc
 
 	trans->net = ctx->net;
 	trans->table = ctx->table;
+	if (trans->table)
+		atomic_inc(&trans->table->cnt);
 	trans->seq = ctx->seq;
 	trans->flags = ctx->flags;
 	trans->report = ctx->report;
@@ -1498,6 +1500,7 @@ static int nf_tables_newtable(struct sk_
 	if (err < 0)
 		goto err_trans;
 
+	atomic_inc(&table->cnt);
 	list_add_tail_rcu(&table->list, &nft_net->tables);
 	return 0;
 err_trans:
@@ -1663,6 +1666,8 @@ static int nf_tables_deltable(struct sk_
 
 static void nf_tables_table_destroy(struct nft_table *table)
 {
+	if (!atomic_dec_and_test(&table->cnt))
+		return;
 	if (WARN_ON(table->use > 0))
 		return;
 
@@ -9532,7 +9537,6 @@ static void nft_commit_release(struct nf
 	switch (trans->msg_type) {
 	case NFT_MSG_DELTABLE:
 	case NFT_MSG_DESTROYTABLE:
-		nf_tables_table_destroy(trans->table);
 		break;
 	case NFT_MSG_NEWCHAIN:
 		free_percpu(nft_trans_chain_stats(trans));
@@ -9572,6 +9576,9 @@ static void nft_commit_release(struct nf
 		break;
 	}
 
+	if (trans->table)
+		nf_tables_table_destroy(trans->table);
+
 	if (trans->put_net)
 		put_net(trans->net);
 
--

  parent reply	other threads:[~2024-07-02 11:28 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-01 20:19 syzbot
2024-07-02  9:39 ` [syzbot] " syzbot
2024-07-02 11:28 ` Hillf Danton [this message]
2024-07-02 13:57   ` syzbot
2024-07-02 13:14 ` Edward Adam Davis
2024-07-02 14:13   ` syzbot
2024-07-02 14:08 ` [PATCH nf] netfilter: nf_tables: unconditionally flush pending work before notifier Florian Westphal
2024-07-03 10:35   ` Hillf Danton
2024-07-03 10:52     ` Florian Westphal
2024-07-03 12:09       ` Hillf Danton
2024-07-03 13:01         ` Florian Westphal
2024-07-04 10:35           ` Hillf Danton
2024-07-04 10:54             ` Florian Westphal
2024-07-05 10:48               ` Hillf Danton
2024-07-05 11:02                 ` Florian Westphal
2024-07-07  7:56                   ` Hillf Danton
2024-07-07  8:08                     ` Florian Westphal
2024-07-08 10:56                       ` Hillf Danton
2024-07-08 11:58                         ` Florian Westphal
2024-07-08 12:17                           ` Hillf Danton
2024-07-08 12:43                             ` Florian Westphal
2024-07-05 11:18                 ` [syzbot] [netfilter?] KASAN: slab-use-after-free Read in nf_tables_trans_destroy_work syzbot
2024-07-02 14:55 ` Edward Adam Davis
2024-07-02 15:28   ` syzbot
2024-07-06 23:13 ` Hillf Danton
2024-07-07  0:21   ` syzbot
     [not found] <20240702093924.GA23593@breakpoint.cc>
2024-07-02 13:33 ` syzbot

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=20240702112814.2760-1-hdanton@sina.com \
    --to=hdanton@sina.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=syzbot+4fd66a69358fc15ae2ad@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®