Skip to content

Commit 3578ca7

Browse files
committed
netfilter: nf_tables: disallow rule addition to bound chain via NFTA_RULE_CHAIN_ID
jira LE-1907 cve CVE-2023-4147 Rebuild_History Non-Buildable kernel-5.14.0-284.30.1.el9_2 commit-author Pablo Neira Ayuso <[email protected]> commit 0ebc106 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 <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]> Signed-off-by: Florian Westphal <[email protected]> (cherry picked from commit 0ebc106) Signed-off-by: Jonathan Maple <[email protected]>
1 parent eabcf73 commit 3578ca7

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
@@ -3460,8 +3460,6 @@ static int nf_tables_newrule(struct sk_buff *skb, const struct nfnl_info *info,
34603460
NL_SET_BAD_ATTR(extack, nla[NFTA_RULE_CHAIN]);
34613461
return PTR_ERR(chain);
34623462
}
3463-
if (nft_chain_is_bound(chain))
3464-
return -EOPNOTSUPP;
34653463

34663464
} else if (nla[NFTA_RULE_CHAIN_ID]) {
34673465
chain = nft_chain_lookup_byid(net, table, nla[NFTA_RULE_CHAIN_ID],
@@ -3474,6 +3472,9 @@ static int nf_tables_newrule(struct sk_buff *skb, const struct nfnl_info *info,
34743472
return -EINVAL;
34753473
}
34763474

3475+
if (nft_chain_is_bound(chain))
3476+
return -EOPNOTSUPP;
3477+
34773478
if (nla[NFTA_RULE_HANDLE]) {
34783479
handle = be64_to_cpu(nla_get_be64(nla[NFTA_RULE_HANDLE]));
34793480
rule = __nft_rule_lookup(chain, handle);

0 commit comments

Comments
 (0)