Skip to content

Commit a1fc1a6

Browse files
committed
netfilter: nf_tables: fix nft_trans type confusion
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2189550 Upstream Status: commit e3c361b commit e3c361b Author: Florian Westphal <fw@strlen.de> Date: Thu May 11 14:15:15 2023 +0200 netfilter: nf_tables: fix nft_trans type confusion 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: 1a94e38 ("netfilter: nf_tables: add NFTA_RULE_ID attribute") Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Florian Westphal <fwestpha@redhat.com>
1 parent c4fdaba commit a1fc1a6

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

net/netfilter/nf_tables_api.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3595,12 +3595,10 @@ static struct nft_rule *nft_rule_lookup_byid(const struct net *net,
35953595
struct nft_trans *trans;
35963596

35973597
list_for_each_entry(trans, &nft_net->commit_list, list) {
3598-
struct nft_rule *rule = nft_trans_rule(trans);
3599-
36003598
if (trans->msg_type == NFT_MSG_NEWRULE &&
36013599
trans->ctx.chain == chain &&
36023600
id == nft_trans_rule_id(trans))
3603-
return rule;
3601+
return nft_trans_rule(trans);
36043602
}
36053603
return ERR_PTR(-ENOENT);
36063604
}

0 commit comments

Comments
 (0)