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)
committerDaniel Borkmann <daniel@iogearbox.net>
Mon, 23 Apr 2018 22:49:45 +0000 (00:49 +0200)
commitba6b8de423f8d0dee48d6030288ed81c03ddf9f0
tree23b0256f0247694e37e4505d239245d1e460bc45
parent4dfe1bb95235c553e216222cf0c377faf191dacd
bpf: sockmap, map_release does not hold refcnt for pinned maps

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>
include/linux/bpf.h
kernel/bpf/arraymap.c
kernel/bpf/sockmap.c
kernel/bpf/syscall.c