Skip to content

Commit 7e6bc1f

Browse files
committed
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. Fixes: 7d74026 ("netfilter: nf_tables: variable sized set element keys / data") Reported-by: Hugues ANGUELKOV <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent f8ebb3a commit 7e6bc1f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

net/netfilter/nf_tables_api.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5213,13 +5213,20 @@ static int nft_setelem_parse_data(struct nft_ctx *ctx, struct nft_set *set,
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
}

0 commit comments

Comments
 (0)