summaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorPeng Sun <sironhide0null@gmail.com>2019-02-26 22:15:37 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-12-05 09:21:13 +0100
commit944df7b4b9dc1a75ec13e48505402bcc96906a89 (patch)
treed7c5562e489e3feabba6d6c76c880428e8afe5d1 /kernel
parentddb2badbe975c95841527aff47107bb44ec47009 (diff)
downloadlinux-stable-944df7b4b9dc1a75ec13e48505402bcc96906a89.tar.gz
linux-stable-944df7b4b9dc1a75ec13e48505402bcc96906a89.tar.bz2
linux-stable-944df7b4b9dc1a75ec13e48505402bcc96906a89.zip
bpf: decrease usercnt if bpf_map_new_fd() fails in bpf_map_get_fd_by_id()
[ Upstream commit 781e62823cb81b972dc8652c1827205cda2ac9ac ] In bpf/syscall.c, bpf_map_get_fd_by_id() use bpf_map_inc_not_zero() to increase the refcount, both map->refcnt and map->usercnt. Then, if bpf_map_new_fd() fails, should handle map->usercnt too. Fixes: bd5f5f4ecb78 ("bpf: Add BPF_MAP_GET_FD_BY_ID") Signed-off-by: Peng Sun <sironhide0null@gmail.com> Acked-by: Martin KaFai Lau <kafai@fb.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/bpf/syscall.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 6e544e364821..90bb0c05c10e 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -1887,7 +1887,7 @@ static int bpf_map_get_fd_by_id(const union bpf_attr *attr)
fd = bpf_map_new_fd(map, f_flags);
if (fd < 0)
- bpf_map_put(map);
+ bpf_map_put_with_uref(map);
return fd;
}