Skip to content

Commit 62e1e94

Browse files
committed
netfilter: nf_tables: reject unbound chain set before commit phase
Use binding list to track set transaction and to check for unbound chains before entering the commit phase. Bail out if chain binding remain unused before entering the commit step. Fixes: d0e2c7d ("netfilter: nf_tables: add NFT_CHAIN_BINDING") Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 938154b commit 62e1e94

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

net/netfilter/nf_tables_api.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,11 @@ static void nft_trans_commit_list_add_tail(struct net *net, struct nft_trans *tr
370370
nft_set_is_anonymous(nft_trans_set(trans)))
371371
list_add_tail(&trans->binding_list, &nft_net->binding_list);
372372
break;
373+
case NFT_MSG_NEWCHAIN:
374+
if (!nft_trans_chain_update(trans) &&
375+
nft_chain_binding(nft_trans_chain(trans)))
376+
list_add_tail(&trans->binding_list, &nft_net->binding_list);
377+
break;
373378
}
374379

375380
list_add_tail(&trans->list, &nft_net->commit_list);
@@ -9501,6 +9506,14 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb)
95019506
return -EINVAL;
95029507
}
95039508
break;
9509+
case NFT_MSG_NEWCHAIN:
9510+
if (!nft_trans_chain_update(trans) &&
9511+
nft_chain_binding(nft_trans_chain(trans)) &&
9512+
!nft_trans_chain_bound(trans)) {
9513+
pr_warn_once("nftables ruleset with unbound chain\n");
9514+
return -EINVAL;
9515+
}
9516+
break;
95049517
}
95059518
}
95069519

0 commit comments

Comments
 (0)