Commit 6bbd9a05 authored by Sasha Levin's avatar Sasha Levin Committed by David S. Miller

bpf: grab rcu read lock for bpf_percpu_hash_update

bpf_percpu_hash_update() expects rcu lock to be held and warns if it's not,
which pointed out a missing rcu read lock.

Fixes: 15a07b33 ("bpf: add lookup/update support for per-cpu hash and array maps")
Signed-off-by: default avatarSasha Levin <sasha.levin@oracle.com>
Acked-by: default avatarAlexei Starovoitov <ast@kernel.org>
Acked-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent dfa2eb86
......@@ -619,7 +619,13 @@ int bpf_percpu_hash_copy(struct bpf_map *map, void *key, void *value)
int bpf_percpu_hash_update(struct bpf_map *map, void *key, void *value,
u64 map_flags)
{
return __htab_percpu_map_update_elem(map, key, value, map_flags, true);
int ret;
rcu_read_lock();
ret = __htab_percpu_map_update_elem(map, key, value, map_flags, true);
rcu_read_unlock();
return ret;
}
static const struct bpf_map_ops htab_percpu_ops = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment