netfilter: nf_tables: fix nft_trans type confusion
Subsystems (2)
Florian Westphal
maintainerPATCH 1/1 netfilter: nf_tables: fix nft_trans type confusion
nft_trans_FOO objects all share a common nft_trans structure, but trailing fields might not ahve been allocated.
This means nft_trans can be treated as nft_trans_FOO only after checking trans->msg_type.
The existing code isn't correct because it treats the object as rule type before the check.
Found by code inspection.
Fixes 1a94e38d254b ("netfilter: nf_tables: add NFTA_RULE_ID attribute")
Signed-off-by Florian Westphal <[email protected]>
--- net/netfilter/nf_tables_api.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
net/netfilter/nf_tables_api.c +1 -3
@@ -3865,12 +3865,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 ); }
Signature · 1 line
2.39.3