@@ -2699,7 +2699,7 @@ static int nf_tables_updchain(struct nft_ctx *ctx, u8 genmask, u8 policy,
26992699
27002700static struct nft_chain * nft_chain_lookup_byid (const struct net * net ,
27012701 const struct nft_table * table ,
2702- const struct nlattr * nla )
2702+ const struct nlattr * nla , u8 genmask )
27032703{
27042704 struct nftables_pernet * nft_net = nft_pernet (net );
27052705 u32 id = ntohl (nla_get_be32 (nla ));
@@ -2710,7 +2710,8 @@ static struct nft_chain *nft_chain_lookup_byid(const struct net *net,
27102710
27112711 if (trans -> msg_type == NFT_MSG_NEWCHAIN &&
27122712 chain -> table == table &&
2713- id == nft_trans_chain_id (trans ))
2713+ id == nft_trans_chain_id (trans ) &&
2714+ nft_active_genmask (chain , genmask ))
27142715 return chain ;
27152716 }
27162717 return ERR_PTR (- ENOENT );
@@ -3814,7 +3815,8 @@ static int nf_tables_newrule(struct sk_buff *skb, const struct nfnl_info *info,
38143815 return - EOPNOTSUPP ;
38153816
38163817 } else if (nla [NFTA_RULE_CHAIN_ID ]) {
3817- chain = nft_chain_lookup_byid (net , table , nla [NFTA_RULE_CHAIN_ID ]);
3818+ chain = nft_chain_lookup_byid (net , table , nla [NFTA_RULE_CHAIN_ID ],
3819+ genmask );
38183820 if (IS_ERR (chain )) {
38193821 NL_SET_BAD_ATTR (extack , nla [NFTA_RULE_CHAIN_ID ]);
38203822 return PTR_ERR (chain );
@@ -10540,7 +10542,8 @@ static int nft_verdict_init(const struct nft_ctx *ctx, struct nft_data *data,
1054010542 genmask );
1054110543 } else if (tb [NFTA_VERDICT_CHAIN_ID ]) {
1054210544 chain = nft_chain_lookup_byid (ctx -> net , ctx -> table ,
10543- tb [NFTA_VERDICT_CHAIN_ID ]);
10545+ tb [NFTA_VERDICT_CHAIN_ID ],
10546+ genmask );
1054410547 if (IS_ERR (chain ))
1054510548 return PTR_ERR (chain );
1054610549 } else {
0 commit comments