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
52135213 struct nft_data *data,
52145214 struct nlattr *attr)
52155215 {
5216+ u32 dtype;
52165217 int err;
52175218
52185219 err = nft_data_init(ctx, data, NFT_DATA_VALUE_MAXLEN, desc, attr);
52195220 if (err < 0)
52205221 return err;
52215222
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) {
52235230 nft_data_release(data, desc->type);
52245231 return -EINVAL;
52255232 }

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