Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions kernel/bpf/hashtab.c
Original file line number Diff line number Diff line change
Expand Up @@ -1977,9 +1977,9 @@ __htab_map_lookup_and_delete_batch(struct bpf_map *map,

rcu_read_unlock();
bpf_enable_instrumentation();
if (bucket_cnt && (copy_to_user(ukeys + total * key_size, keys,
if (bucket_cnt && (copy_to_user(ukeys + (size_t)total * key_size, keys,
key_size * bucket_cnt) ||
copy_to_user(uvalues + total * value_size, values,
copy_to_user(uvalues + (size_t)total * value_size, values,
value_size * bucket_cnt))) {
ret = -EFAULT;
goto after_loop;
Expand Down
10 changes: 5 additions & 5 deletions kernel/bpf/syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -2036,7 +2036,7 @@ int generic_map_delete_batch(struct bpf_map *map,

for (cp = 0; cp < max_count; cp++) {
err = -EFAULT;
if (copy_from_user(key, keys + cp * map->key_size,
if (copy_from_user(key, keys + (size_t)cp * map->key_size,
map->key_size))
break;

Expand Down Expand Up @@ -2098,9 +2098,9 @@ int generic_map_update_batch(struct bpf_map *map, struct file *map_file,

for (cp = 0; cp < max_count; cp++) {
err = -EFAULT;
if (copy_from_user(key, keys + cp * map->key_size,
if (copy_from_user(key, keys + (size_t)cp * map->key_size,
map->key_size) ||
copy_from_user(value, values + cp * value_size, value_size))
copy_from_user(value, values + (size_t)cp * value_size, value_size))
break;

err = bpf_map_update_value(map, map_file, key, value,
Expand Down Expand Up @@ -2179,12 +2179,12 @@ int generic_map_lookup_batch(struct bpf_map *map,
if (err)
goto free_buf;

if (copy_to_user(keys + cp * map->key_size, key,
if (copy_to_user(keys + (size_t)cp * map->key_size, key,
map->key_size)) {
err = -EFAULT;
goto free_buf;
}
if (copy_to_user(values + cp * value_size, value, value_size)) {
if (copy_to_user(values + (size_t)cp * value_size, value, value_size)) {
err = -EFAULT;
goto free_buf;
}
Expand Down
Loading