diff options
author | Daniel Borkmann <daniel@iogearbox.net> | 2016-06-15 16:47:13 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-06-16 02:42:57 -0400 |
commit | d056a788765e67773124f520159185bc89f5d1ad (patch) | |
tree | 206983a7a6cad6687929f48147bef8e4de3c0ba2 /kernel/bpf/syscall.c | |
parent | 61d1b6a42fec61c5065f54cc62cef02b483c69fb (diff) |
bpf, maps: extend map_fd_get_ptr arguments
This patch extends map_fd_get_ptr() callback that is used by fd array
maps, so that struct file pointer from the related map can be passed
in. It's safe to remove map_update_elem() callback for the two maps since
this is only allowed from syscall side, but not from eBPF programs for these
two map types. Like in per-cpu map case, bpf_fd_array_map_update_elem()
needs to be called directly here due to the extra argument.
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'kernel/bpf/syscall.c')
-rw-r--r-- | kernel/bpf/syscall.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index fc3adcd064b1..c23a4e9311b3 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c | |||
@@ -392,6 +392,12 @@ static int map_update_elem(union bpf_attr *attr) | |||
392 | err = bpf_percpu_hash_update(map, key, value, attr->flags); | 392 | err = bpf_percpu_hash_update(map, key, value, attr->flags); |
393 | } else if (map->map_type == BPF_MAP_TYPE_PERCPU_ARRAY) { | 393 | } else if (map->map_type == BPF_MAP_TYPE_PERCPU_ARRAY) { |
394 | err = bpf_percpu_array_update(map, key, value, attr->flags); | 394 | err = bpf_percpu_array_update(map, key, value, attr->flags); |
395 | } else if (map->map_type == BPF_MAP_TYPE_PERF_EVENT_ARRAY || | ||
396 | map->map_type == BPF_MAP_TYPE_PROG_ARRAY) { | ||
397 | rcu_read_lock(); | ||
398 | err = bpf_fd_array_map_update_elem(map, f.file, key, value, | ||
399 | attr->flags); | ||
400 | rcu_read_unlock(); | ||
395 | } else { | 401 | } else { |
396 | rcu_read_lock(); | 402 | rcu_read_lock(); |
397 | err = map->ops->map_update_elem(map, key, value, attr->flags); | 403 | err = map->ops->map_update_elem(map, key, value, attr->flags); |