Skip to content

Commit 335178d

Browse files
Florian Westphalummakynes
authored andcommitted
netfilter: nf_tables: fix flowtable list del corruption
syzbot reported following crash: list_del corruption, ffff88808c9bb000->prev is LIST_POISON2 (dead000000000122) [..] Call Trace: __list_del_entry include/linux/list.h:131 [inline] list_del_rcu include/linux/rculist.h:148 [inline] nf_tables_commit+0x1068/0x3b30 net/netfilter/nf_tables_api.c:7183 [..] The commit transaction list has: NFT_MSG_NEWTABLE NFT_MSG_NEWFLOWTABLE NFT_MSG_DELFLOWTABLE NFT_MSG_DELTABLE A missing generation check during DELTABLE processing causes it to queue the DELFLOWTABLE operation a second time, so we corrupt the list here: case NFT_MSG_DELFLOWTABLE: list_del_rcu(&nft_trans_flowtable(trans)->list); nf_tables_flowtable_notify(&trans->ctx, because we have two different DELFLOWTABLE transactions for the same flowtable. We then call list_del_rcu() twice for the same flowtable->list. The object handling seems to suffer from the same bug so add a generation check too and only queue delete transactions for flowtables/objects that are still active in the next generation. Reported-by: [email protected] Fixes: 3b49e2e ("netfilter: nf_tables: add flow table netlink frontend") Signed-off-by: Florian Westphal <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent cd77e75 commit 335178d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

net/netfilter/nf_tables_api.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,12 +1048,18 @@ static int nft_flush_table(struct nft_ctx *ctx)
10481048
}
10491049

10501050
list_for_each_entry_safe(flowtable, nft, &ctx->table->flowtables, list) {
1051+
if (!nft_is_active_next(ctx->net, flowtable))
1052+
continue;
1053+
10511054
err = nft_delflowtable(ctx, flowtable);
10521055
if (err < 0)
10531056
goto out;
10541057
}
10551058

10561059
list_for_each_entry_safe(obj, ne, &ctx->table->objects, list) {
1060+
if (!nft_is_active_next(ctx->net, obj))
1061+
continue;
1062+
10571063
err = nft_delobj(ctx, obj);
10581064
if (err < 0)
10591065
goto out;

0 commit comments

Comments
 (0)