summaryrefslogtreecommitdiffstats
path: root/kernel/bpf/syscall.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/bpf/syscall.c')
-rw-r--r--kernel/bpf/syscall.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 5d141f16f6fa..cf8052b016e7 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -683,8 +683,8 @@ struct bpf_map *bpf_map_get_with_uref(u32 ufd)
683} 683}
684 684
685/* map_idr_lock should have been held */ 685/* map_idr_lock should have been held */
686static struct bpf_map *bpf_map_inc_not_zero(struct bpf_map *map, 686static struct bpf_map *__bpf_map_inc_not_zero(struct bpf_map *map,
687 bool uref) 687 bool uref)
688{ 688{
689 int refold; 689 int refold;
690 690
@@ -704,6 +704,16 @@ static struct bpf_map *bpf_map_inc_not_zero(struct bpf_map *map,
704 return map; 704 return map;
705} 705}
706 706
707struct bpf_map *bpf_map_inc_not_zero(struct bpf_map *map, bool uref)
708{
709 spin_lock_bh(&map_idr_lock);
710 map = __bpf_map_inc_not_zero(map, uref);
711 spin_unlock_bh(&map_idr_lock);
712
713 return map;
714}
715EXPORT_SYMBOL_GPL(bpf_map_inc_not_zero);
716
707int __weak bpf_stackmap_copy(struct bpf_map *map, void *key, void *value) 717int __weak bpf_stackmap_copy(struct bpf_map *map, void *key, void *value)
708{ 718{
709 return -ENOTSUPP; 719 return -ENOTSUPP;
@@ -2177,7 +2187,7 @@ static int bpf_map_get_fd_by_id(const union bpf_attr *attr)
2177 spin_lock_bh(&map_idr_lock); 2187 spin_lock_bh(&map_idr_lock);
2178 map = idr_find(&map_idr, id); 2188 map = idr_find(&map_idr, id);
2179 if (map) 2189 if (map)
2180 map = bpf_map_inc_not_zero(map, true); 2190 map = __bpf_map_inc_not_zero(map, true);
2181 else 2191 else
2182 map = ERR_PTR(-ENOENT); 2192 map = ERR_PTR(-ENOENT);
2183 spin_unlock_bh(&map_idr_lock); 2193 spin_unlock_bh(&map_idr_lock);