Skip to content

Commit e3c361b

Browse files
author
Florian Westphal
committed
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 <[email protected]>
1 parent 224a876 commit e3c361b

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
@@ -3865,12 +3865,10 @@ static struct nft_rule *nft_rule_lookup_byid(const struct net *net,
38653865
struct nft_trans *trans;
38663866

38673867
list_for_each_entry(trans, &nft_net->commit_list, list) {
3868-
struct nft_rule *rule = nft_trans_rule(trans);
3869-
38703868
if (trans->msg_type == NFT_MSG_NEWRULE &&
38713869
trans->ctx.chain == chain &&
38723870
id == nft_trans_rule_id(trans))
3873-
return rule;
3871+
return nft_trans_rule(trans);
38743872
}
38753873
return ERR_PTR(-ENOENT);
38763874
}

0 commit comments

Comments
 (0)