Skip to content

Commit 51f6ae5

Browse files
committed
netfilter: nf_tables: reject unbound chain set before commit phase
JIRA: https://issues.redhat.com/browse/RHEL-1720 JIRA: https://issues.redhat.com/browse/RHEL-1721 Upstream Status: commit 62e1e94 commit 62e1e94 Author: Pablo Neira Ayuso <[email protected]> Date: Fri Jun 16 15:21:39 2023 +0200 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]> Signed-off-by: Florian Westphal <[email protected]>
1 parent 5a63039 commit 51f6ae5

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
@@ -372,6 +372,11 @@ static void nft_trans_commit_list_add_tail(struct net *net, struct nft_trans *tr
372372
nft_set_is_anonymous(nft_trans_set(trans)))
373373
list_add_tail(&trans->binding_list, &nft_net->binding_list);
374374
break;
375+
case NFT_MSG_NEWCHAIN:
376+
if (!nft_trans_chain_update(trans) &&
377+
nft_chain_binding(nft_trans_chain(trans)))
378+
list_add_tail(&trans->binding_list, &nft_net->binding_list);
379+
break;
375380
}
376381

377382
list_add_tail(&trans->list, &nft_net->commit_list);
@@ -9206,6 +9211,14 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb)
92069211
return -EINVAL;
92079212
}
92089213
break;
9214+
case NFT_MSG_NEWCHAIN:
9215+
if (!nft_trans_chain_update(trans) &&
9216+
nft_chain_binding(nft_trans_chain(trans)) &&
9217+
!nft_trans_chain_bound(trans)) {
9218+
pr_warn_once("nftables ruleset with unbound chain\n");
9219+
return -EINVAL;
9220+
}
9221+
break;
92099222
}
92109223
}
92119224

0 commit comments

Comments
 (0)