History

netfilter: nf_tables: stricter validation of element data

Make sure element data type and length do not mismatch the one specified by the set declaration.

Pablo Neira Ayuso committed 4 years ago

Commit 7e6bc1f1 parent f8ebb3a1 file · +8 −1Browse files

Unified · Split

net/netfilter/nf_tables_api.c+8−1
@@ -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 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t