Skip to content

Commit 8122af3

Browse files
committed
netfilter: nf_tables: fix nft_trans type confusion
jira VUlN-597 subsystem-sync netfilter:nf_tables 4.18.0-511 commit-author Florian Westphal <[email protected]> commit e3c361b upstream-diff - Some cruft in nft_rule_lookup_byid() - resolved by using branch 8_10 as the source of truth. 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]> (cherry picked from commit e3c361b) Signed-off-by: Greg Rose <[email protected]>
1 parent 007aea7 commit 8122af3

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

net/netfilter/nf_tables_api.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -3330,12 +3330,10 @@ static struct nft_rule *nft_rule_lookup_byid(const struct net *net,
33303330
struct nft_trans *trans;
33313331

33323332
list_for_each_entry(trans, &net->nft.commit_list, list) {
3333-
struct nft_rule *rule = nft_trans_rule(trans);
3334-
33353333
if (trans->msg_type == NFT_MSG_NEWRULE &&
33363334
trans->ctx.chain == chain &&
33373335
id == nft_trans_rule_id(trans))
3338-
return rule;
3336+
return nft_trans_rule(trans);
33393337
}
33403338
return ERR_PTR(-ENOENT);
33413339
}

0 commit comments

Comments
 (0)