Revert "bpf: Fix DEVMAP_HASH overflow check on 32-bit arches"
This reverts commit 736d05560d
.
This commit is contained in:
parent
ad9cd009c0
commit
78f121c9d6
1 changed files with 3 additions and 6 deletions
|
@ -131,13 +131,10 @@ static int dev_map_init_map(struct bpf_dtab *dtab, union bpf_attr *attr)
|
||||||
bpf_map_init_from_attr(&dtab->map, attr);
|
bpf_map_init_from_attr(&dtab->map, attr);
|
||||||
|
|
||||||
if (attr->map_type == BPF_MAP_TYPE_DEVMAP_HASH) {
|
if (attr->map_type == BPF_MAP_TYPE_DEVMAP_HASH) {
|
||||||
/* hash table size must be power of 2; roundup_pow_of_two() can
|
|
||||||
* overflow into UB on 32-bit arches, so check that first
|
|
||||||
*/
|
|
||||||
if (dtab->map.max_entries > 1UL << 31)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
dtab->n_buckets = roundup_pow_of_two(dtab->map.max_entries);
|
dtab->n_buckets = roundup_pow_of_two(dtab->map.max_entries);
|
||||||
|
|
||||||
|
if (!dtab->n_buckets) /* Overflow check */
|
||||||
|
return -EINVAL;
|
||||||
cost += (u64) sizeof(struct hlist_head) * dtab->n_buckets;
|
cost += (u64) sizeof(struct hlist_head) * dtab->n_buckets;
|
||||||
} else {
|
} else {
|
||||||
cost += (u64) dtab->map.max_entries * sizeof(struct bpf_dtab_netdev *);
|
cost += (u64) dtab->map.max_entries * sizeof(struct bpf_dtab_netdev *);
|
||||||
|
|
Loading…
Reference in a new issue