mirror of
https://github.com/hardkernel/linux.git
synced 2026-03-25 12:00:22 +09:00
netfilter: nf_tables: fix nft_trans type confusion
[ Upstream commite3c361b8ac] nft_trans_FOO objects all share a common nft_trans base structure, but trailing fields depend on the real object size. Access is only safe after trans->msg_type check. Check for rule type first. Found by code inspection. Fixes:1a94e38d25("netfilter: nf_tables: add NFTA_RULE_ID attribute") Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
addaba6801
commit
b0cc763806
@@ -3595,12 +3595,10 @@ static struct nft_rule *nft_rule_lookup_byid(const struct net *net,
|
||||
struct nft_trans *trans;
|
||||
|
||||
list_for_each_entry(trans, &nft_net->commit_list, list) {
|
||||
struct nft_rule *rule = nft_trans_rule(trans);
|
||||
|
||||
if (trans->msg_type == NFT_MSG_NEWRULE &&
|
||||
trans->ctx.chain == chain &&
|
||||
id == nft_trans_rule_id(trans))
|
||||
return rule;
|
||||
return nft_trans_rule(trans);
|
||||
}
|
||||
return ERR_PTR(-ENOENT);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user