Make sure element data type and length do not mismatch the one specified by the set declaration.
Unified · Split
| @@ -5213,13 +5213,20 @@ static int nft_setelem_parse_data(struct nft_ctx *ctx, struct nft_set *set, · 5212 unmodified lines | |||
| 5213 | struct nft_data *data, | 5213 | struct nft_data *data, |
| 5214 | struct nlattr *attr) | 5214 | struct nlattr *attr) |
| 5215 | { | 5215 | { |
| 5216 | u32 dtype; | ||
| 5216 | int err; | 5217 | int err; |
| 5217 | 5218 | ||
| 5218 | err = nft_data_init(ctx, data, NFT_DATA_VALUE_MAXLEN, desc, attr); | 5219 | err = nft_data_init(ctx, data, NFT_DATA_VALUE_MAXLEN, desc, attr); |
| 5219 | if (err < 0) | 5220 | if (err < 0) |
| 5220 | return err; | 5221 | return err; |
| 5221 | 5222 | ||
| 5222 | if (desc->type != NFT_DATA_VERDICT && desc->len != set->dlen) { | 5223 | if (set->dtype == NFT_DATA_VERDICT) |
| 5224 | dtype = NFT_DATA_VERDICT; | ||
| 5225 | else | ||
| 5226 | dtype = NFT_DATA_VALUE; | ||
| 5227 | |||
| 5228 | if (dtype != desc->type || | ||
| 5229 | set->dlen != desc->len) { | ||
| 5223 | nft_data_release(data, desc->type); | 5230 | nft_data_release(data, desc->type); |
| 5224 | return -EINVAL; | 5231 | return -EINVAL; |
| 5225 | } | 5232 | } |