Skip to content

Commit 268cb07

Browse files
ummakynesgregkh
authored andcommitted
netfilter: nf_tables: disallow rule addition to bound chain via NFTA_RULE_CHAIN_ID
[ Upstream 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 <kevinrich1337@gmail.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 4237462 commit 268cb07

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
@@ -3626,8 +3626,6 @@ static int nf_tables_newrule(struct sk_buff *skb, const struct nfnl_info *info,
36263626
NL_SET_BAD_ATTR(extack, nla[NFTA_RULE_CHAIN]);
36273627
return PTR_ERR(chain);
36283628
}
3629-
if (nft_chain_is_bound(chain))
3630-
return -EOPNOTSUPP;
36313629

36323630
} else if (nla[NFTA_RULE_CHAIN_ID]) {
36333631
chain = nft_chain_lookup_byid(net, table, nla[NFTA_RULE_CHAIN_ID],
@@ -3640,6 +3638,9 @@ static int nf_tables_newrule(struct sk_buff *skb, const struct nfnl_info *info,
36403638
return -EINVAL;
36413639
}
36423640

3641+
if (nft_chain_is_bound(chain))
3642+
return -EOPNOTSUPP;
3643+
36433644
if (nla[NFTA_RULE_HANDLE]) {
36443645
handle = be64_to_cpu(nla_get_be64(nla[NFTA_RULE_HANDLE]));
36453646
rule = __nft_rule_lookup(chain, handle);

0 commit comments

Comments
 (0)