Skip to content

Commit e287383

Browse files
committed
netfilter: nf_tables: disallow rule addition to bound chain via NFTA_RULE_CHAIN_ID
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2225271 Upstream Status: commit 0ebc106 CVE: CVE-2023-4147 commit 0ebc106 Author: Pablo Neira Ayuso <pablo@netfilter.org> Date: Sun Jul 23 16:41:48 2023 +0200 netfilter: nf_tables: disallow rule addition to bound chain via NFTA_RULE_CHAIN_ID Bail out with EOPNOTSUPP when adding rule to bound chain via NFTA_RULE_CHAIN_ID. The following warning splat is shown when adding a rule to a deleted bound chain: WARNING: CPU: 2 PID: 13692 at net/netfilter/nf_tables_api.c:2013 nf_tables_chain_destroy+0x1f7/0x210 [nf_tables] CPU: 2 PID: 13692 Comm: chain-bound-rul Not tainted 6.1.39 #1 RIP: 0010:nf_tables_chain_destroy+0x1f7/0x210 [nf_tables] Fixes: d0e2c7d ("netfilter: nf_tables: add NFT_CHAIN_BINDING") Reported-by: Kevin Rich <kevinrich1337@gmail.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Phil Sutter <psutter@redhat.com>
1 parent e22cca3 commit e287383

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

net/netfilter/nf_tables_api.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3401,8 +3401,6 @@ static int nf_tables_newrule(struct sk_buff *skb, const struct nfnl_info *info,
34013401
NL_SET_BAD_ATTR(extack, nla[NFTA_RULE_CHAIN]);
34023402
return PTR_ERR(chain);
34033403
}
3404-
if (nft_chain_is_bound(chain))
3405-
return -EOPNOTSUPP;
34063404

34073405
} else if (nla[NFTA_RULE_CHAIN_ID]) {
34083406
chain = nft_chain_lookup_byid(net, table, nla[NFTA_RULE_CHAIN_ID],
@@ -3415,6 +3413,9 @@ static int nf_tables_newrule(struct sk_buff *skb, const struct nfnl_info *info,
34153413
return -EINVAL;
34163414
}
34173415

3416+
if (nft_chain_is_bound(chain))
3417+
return -EOPNOTSUPP;
3418+
34183419
if (nla[NFTA_RULE_HANDLE]) {
34193420
handle = be64_to_cpu(nla_get_be64(nla[NFTA_RULE_HANDLE]));
34203421
rule = __nft_rule_lookup(chain, handle);

0 commit comments

Comments
 (0)