Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1337854 > unrolled thread
| Started by | Sasha Levin <sasha.levin@oracle.com> |
|---|---|
| First post | 2016-02-19 04:00 +0100 |
| Last post | 2016-02-19 04:20 +0100 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH] bpf: grab rcu read lock for bpf_percpu_hash_update Sasha Levin <sasha.levin@oracle.com> - 2016-02-19 04:00 +0100
Re: [PATCH] bpf: grab rcu read lock for bpf_percpu_hash_update Alexei Starovoitov <alexei.starovoitov@gmail.com> - 2016-02-19 04:20 +0100
| From | Sasha Levin <sasha.levin@oracle.com> |
|---|---|
| Date | 2016-02-19 04:00 +0100 |
| Subject | [PATCH] bpf: grab rcu read lock for bpf_percpu_hash_update |
| Message-ID | <r3Jsu-6IV-11@gated-at.bofh.it> |
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: 15a07b338 ("bpf: add lookup/update support for per-cpu hash and array maps")
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
kernel/bpf/syscall.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index c95a753..94324b8 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -348,7 +348,9 @@ static int map_update_elem(union bpf_attr *attr)
goto free_value;
if (map->map_type == BPF_MAP_TYPE_PERCPU_HASH) {
+ rcu_read_lock();
err = bpf_percpu_hash_update(map, key, value, attr->flags);
+ rcu_read_unlock();
} else if (map->map_type == BPF_MAP_TYPE_PERCPU_ARRAY) {
err = bpf_percpu_array_update(map, key, value, attr->flags);
} else {
--
1.7.10.4
[toc] | [next] | [standalone]
| From | Alexei Starovoitov <alexei.starovoitov@gmail.com> |
|---|---|
| Date | 2016-02-19 04:20 +0100 |
| Message-ID | <r3JLP-7bz-5@gated-at.bofh.it> |
| In reply to | #1337854 |
On Thu, Feb 18, 2016 at 09:56:22PM -0500, Sasha Levin wrote:
> 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: 15a07b338 ("bpf: add lookup/update support for per-cpu hash and array maps")
> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
> ---
> kernel/bpf/syscall.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
> index c95a753..94324b8 100644
> --- a/kernel/bpf/syscall.c
> +++ b/kernel/bpf/syscall.c
> @@ -348,7 +348,9 @@ static int map_update_elem(union bpf_attr *attr)
> goto free_value;
>
> if (map->map_type == BPF_MAP_TYPE_PERCPU_HASH) {
> + rcu_read_lock();
> err = bpf_percpu_hash_update(map, key, value, attr->flags);
> + rcu_read_unlock();
good catch. thanks, but could you add rcu_read_lock/unlock
inside bpf_percpu_hash_update() instead... to match what
bpf_percpu_hash_copy/bpf_percpu_array_update/bpf_percpu_array_copy are doing.
Otherwise it's inconsistent.
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web