]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
bpf: sockmap, map_release does not hold refcnt for pinned maps
authorJohn Fastabend <john.fastabend@gmail.com>
Mon, 23 Apr 2018 22:39:23 +0000 (15:39 -0700)
committerJuerg Haefliger <juergh@canonical.com>
Wed, 24 Jul 2019 01:55:07 +0000 (19:55 -0600)
commit458397ab8ff75cdc205d9115058caf79b57a5310
tree275635931e886310c9f6b34cb3443561221f8ba0
parenta7e04d1b95eb0cca8c2391518aaefa35813011e8
bpf: sockmap, map_release does not hold refcnt for pinned maps

BugLink: https://bugs.launchpad.net/bugs/1836654
[ Upstream commit ba6b8de423f8d0dee48d6030288ed81c03ddf9f0 ]

Relying on map_release hook to decrement the reference counts when a
map is removed only works if the map is not being pinned. In the
pinned case the ref is decremented immediately and the BPF programs
released. After this BPF programs may not be in-use which is not
what the user would expect.

This patch moves the release logic into bpf_map_put_uref() and brings
sockmap in-line with how a similar case is handled in prog array maps.

Fixes: 3d9e952697de ("bpf: sockmap, fix leaking maps with attached but not detached progs")
Signed-off-by: John Fastabend <john.fastabend@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
include/linux/bpf.h
kernel/bpf/arraymap.c
kernel/bpf/sockmap.c
kernel/bpf/syscall.c