Skip to content

Commit

Permalink
bpf: grab rcu read lock for bpf_percpu_hash_update
Browse files Browse the repository at this point in the history
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: 15a07b3 ("bpf: add lookup/update support for per-cpu hash and array maps")
Signed-off-by: Sasha Levin <[email protected]>
Acked-by: Alexei Starovoitov <[email protected]>
Acked-by: Daniel Borkmann <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
sashalevin authored and davem330 committed Feb 19, 2016
1 parent dfa2eb8 commit 6bbd9a0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion kernel/bpf/hashtab.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down

0 comments on commit 6bbd9a0

Please sign in to comment.