netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] bpf: grab rcu read lock for bpf_percpu_hash_update
@ 2016-02-19 18:53 Sasha Levin
  2016-02-19 18:56 ` Alexei Starovoitov
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Sasha Levin @ 2016-02-19 18:53 UTC (permalink / raw)
  To: ast; +Cc: netdev, linux-kernel, davem, Sasha Levin

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/hashtab.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/kernel/bpf/hashtab.c b/kernel/bpf/hashtab.c
index fd5db8f..a68e951 100644
--- a/kernel/bpf/hashtab.c
+++ b/kernel/bpf/hashtab.c
@@ -619,7 +619,13 @@ out:
 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 = {
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] bpf: grab rcu read lock for bpf_percpu_hash_update
  2016-02-19 18:53 [PATCH v2] bpf: grab rcu read lock for bpf_percpu_hash_update Sasha Levin
@ 2016-02-19 18:56 ` Alexei Starovoitov
  2016-02-19 19:02 ` Daniel Borkmann
  2016-02-19 19:41 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Alexei Starovoitov @ 2016-02-19 18:56 UTC (permalink / raw)
  To: Sasha Levin; +Cc: ast, netdev, linux-kernel, davem

On Fri, Feb 19, 2016 at 01:53:10PM -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>

thank you.
Acked-by: Alexei Starovoitov <ast@kernel.org>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] bpf: grab rcu read lock for bpf_percpu_hash_update
  2016-02-19 18:53 [PATCH v2] bpf: grab rcu read lock for bpf_percpu_hash_update Sasha Levin
  2016-02-19 18:56 ` Alexei Starovoitov
@ 2016-02-19 19:02 ` Daniel Borkmann
  2016-02-19 19:41 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Daniel Borkmann @ 2016-02-19 19:02 UTC (permalink / raw)
  To: Sasha Levin, ast; +Cc: netdev, linux-kernel, davem

On 02/19/2016 07:53 PM, 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>

LGTM, patch is against net-next tree.

Acked-by: Daniel Borkmann <daniel@iogearbox.net>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] bpf: grab rcu read lock for bpf_percpu_hash_update
  2016-02-19 18:53 [PATCH v2] bpf: grab rcu read lock for bpf_percpu_hash_update Sasha Levin
  2016-02-19 18:56 ` Alexei Starovoitov
  2016-02-19 19:02 ` Daniel Borkmann
@ 2016-02-19 19:41 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2016-02-19 19:41 UTC (permalink / raw)
  To: sasha.levin; +Cc: ast, netdev, linux-kernel

From: Sasha Levin <sasha.levin@oracle.com>
Date: Fri, 19 Feb 2016 13:53:10 -0500

> 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>

Applied, thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-02-19 19:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-19 18:53 [PATCH v2] bpf: grab rcu read lock for bpf_percpu_hash_update Sasha Levin
2016-02-19 18:56 ` Alexei Starovoitov
2016-02-19 19:02 ` Daniel Borkmann
2016-02-19 19:41 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).