summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/linux/bpf.h2
-rw-r--r--kernel/bpf/arraymap.c6
-rw-r--r--kernel/bpf/syscall.c8
3 files changed, 6 insertions, 10 deletions
diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index d1a17c118316..c0510d223685 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -111,7 +111,7 @@ struct bpf_map_ops {
long (*map_pop_elem)(struct bpf_map *map, void *value);
long (*map_peek_elem)(struct bpf_map *map, void *value);
void *(*map_lookup_percpu_elem)(struct bpf_map *map, void *key, u32 cpu);
- int (*map_get_hash)(struct bpf_map *map, u32 hash_buf_size, void *hash_buf);
+ int (*map_get_hash)(struct bpf_map *map);
/* funcs called by prog_array and perf_event_array map */
void *(*map_fd_get_ptr)(struct bpf_map *map, struct file *map_file,
diff --git a/kernel/bpf/arraymap.c b/kernel/bpf/arraymap.c
index dfb2110ab733..e6271a2bf6d6 100644
--- a/kernel/bpf/arraymap.c
+++ b/kernel/bpf/arraymap.c
@@ -175,14 +175,12 @@ static void *array_map_lookup_elem(struct bpf_map *map, void *key)
return array->value + (u64)array->elem_size * (index & array->index_mask);
}
-static int array_map_get_hash(struct bpf_map *map, u32 hash_buf_size,
- void *hash_buf)
+static int array_map_get_hash(struct bpf_map *map)
{
struct bpf_array *array = container_of(map, struct bpf_array, map);
sha256(array->value, (u64)array->elem_size * array->map.max_entries,
- hash_buf);
- memcpy(array->map.sha, hash_buf, sizeof(array->map.sha));
+ array->map.sha);
return 0;
}
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 2aafd2131983..a27fa2b9b405 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -5434,18 +5434,16 @@ static int bpf_map_get_info_by_fd(struct file *file,
if (!map->ops->map_get_hash)
return -EINVAL;
-
- if (info.hash_size != SHA256_DIGEST_SIZE)
+ if (info.hash_size != sizeof(map->sha))
return -EINVAL;
-
if (!READ_ONCE(map->frozen))
return -EPERM;
- err = map->ops->map_get_hash(map, SHA256_DIGEST_SIZE, map->sha);
+ err = map->ops->map_get_hash(map);
if (err != 0)
return err;
- if (copy_to_user(uhash, map->sha, SHA256_DIGEST_SIZE) != 0)
+ if (copy_to_user(uhash, map->sha, sizeof(map->sha)) != 0)
return -EFAULT;
} else if (info.hash_size) {
return -EINVAL;