@@ -2458,7 +2458,7 @@ static int nf_tables_updchain(struct nft_ctx *ctx, u8 genmask, u8 policy,
24582458
24592459static struct nft_chain * nft_chain_lookup_byid (const struct net * net ,
24602460 const struct nft_table * table ,
2461- const struct nlattr * nla )
2461+ const struct nlattr * nla , u8 genmask )
24622462{
24632463 struct nftables_pernet * nft_net = nft_pernet (net );
24642464 u32 id = ntohl (nla_get_be32 (nla ));
@@ -2469,7 +2469,8 @@ static struct nft_chain *nft_chain_lookup_byid(const struct net *net,
24692469
24702470 if (trans -> msg_type == NFT_MSG_NEWCHAIN &&
24712471 chain -> table == table &&
2472- id == nft_trans_chain_id (trans ))
2472+ id == nft_trans_chain_id (trans ) &&
2473+ nft_active_genmask (chain , genmask ))
24732474 return chain ;
24742475 }
24752476 return ERR_PTR (- ENOENT );
@@ -3463,7 +3464,8 @@ static int nf_tables_newrule(struct sk_buff *skb, const struct nfnl_info *info,
34633464 return - EOPNOTSUPP ;
34643465
34653466 } else if (nla [NFTA_RULE_CHAIN_ID ]) {
3466- chain = nft_chain_lookup_byid (net , table , nla [NFTA_RULE_CHAIN_ID ]);
3467+ chain = nft_chain_lookup_byid (net , table , nla [NFTA_RULE_CHAIN_ID ],
3468+ genmask );
34673469 if (IS_ERR (chain )) {
34683470 NL_SET_BAD_ATTR (extack , nla [NFTA_RULE_CHAIN_ID ]);
34693471 return PTR_ERR (chain );
@@ -9732,7 +9734,8 @@ static int nft_verdict_init(const struct nft_ctx *ctx, struct nft_data *data,
97329734 genmask );
97339735 } else if (tb [NFTA_VERDICT_CHAIN_ID ]) {
97349736 chain = nft_chain_lookup_byid (ctx -> net , ctx -> table ,
9735- tb [NFTA_VERDICT_CHAIN_ID ]);
9737+ tb [NFTA_VERDICT_CHAIN_ID ],
9738+ genmask );
97369739 if (IS_ERR (chain ))
97379740 return PTR_ERR (chain );
97389741 } else {
0 commit comments