]> git.baikalelectronics.ru Git - 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)
committerDaniel Borkmann <daniel@iogearbox.net>
Mon, 23 Apr 2018 22:49:45 +0000 (00:49 +0200)
commit532e55acf312faa0782e81b082824e00d0ebbdbe
tree23b0256f0247694e37e4505d239245d1e460bc45
parent9f60db983d0bdcd9f54e3c08159edea046f357ed
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: 92fb26cd4478 ("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