Skip to content

Commit ab50d0e

Browse files
ummakynesgregkh
authored andcommitted
netfilter: nf_tables: reject mismatching sum of field_len with set key length
commit 1b9335a upstream. The field length description provides the length of each separated key field in the concatenation, each field gets rounded up to 32-bits to calculate the pipapo rule width from pipapo_init(). The set key length provides the total size of the key aligned to 32-bits. Register-based arithmetics still allows for combining mismatching set key length and field length description, eg. set key length 10 and field description [ 5, 4 ] leading to pipapo width of 12. Cc: [email protected] Fixes: 3ce67e3 ("netfilter: nf_tables: do not allow mismatch field size and set key length") Reported-by: Noam Rathaus <[email protected]> Reviewed-by: Florian Westphal <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 5d08d43 commit ab50d0e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

net/netfilter/nf_tables_api.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5074,7 +5074,7 @@ static int nft_set_desc_concat_parse(const struct nlattr *attr,
50745074
static int nft_set_desc_concat(struct nft_set_desc *desc,
50755075
const struct nlattr *nla)
50765076
{
5077-
u32 num_regs = 0, key_num_regs = 0;
5077+
u32 len = 0, num_regs;
50785078
struct nlattr *attr;
50795079
int rem, err, i;
50805080

@@ -5088,12 +5088,12 @@ static int nft_set_desc_concat(struct nft_set_desc *desc,
50885088
}
50895089

50905090
for (i = 0; i < desc->field_count; i++)
5091-
num_regs += DIV_ROUND_UP(desc->field_len[i], sizeof(u32));
5091+
len += round_up(desc->field_len[i], sizeof(u32));
50925092

5093-
key_num_regs = DIV_ROUND_UP(desc->klen, sizeof(u32));
5094-
if (key_num_regs != num_regs)
5093+
if (len != desc->klen)
50955094
return -EINVAL;
50965095

5096+
num_regs = DIV_ROUND_UP(desc->klen, sizeof(u32));
50975097
if (num_regs > NFT_REG32_COUNT)
50985098
return -E2BIG;
50995099

0 commit comments

Comments
 (0)