linux/kernel/bpf
Daniel Borkmann 592867bfab ebpf: fix fd refcount leaks related to maps in bpf syscall
We may already have gotten a proper fd struct through fdget(), so
whenever we return at the end of an map operation, we need to call
fdput(). However, each map operation from syscall side first probes
CHECK_ATTR() to verify that unused fields in the bpf_attr union are
zero.

In case of malformed input, we return with error, but the lookup to
the map_fd was already performed at that time, so that we return
without an corresponding fdput(). Fix it by performing an fdget()
only right before bpf_map_get(). The fdget() invocation on maps in
the verifier is not affected.

Fixes: db20fd2b01 ("bpf: add lookup/update/delete/iterate methods to BPF maps")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@plumgrid.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-09-09 12:39:34 -07:00
..
arraymap.c bpf: Add new bpf map type to store the pointer to struct perf_event 2015-08-09 22:50:05 -07:00
core.c bpf: Make the bpf_prog_array_map more generic 2015-08-09 22:50:05 -07:00
hashtab.c ebpf: constify various function pointer structs 2015-03-01 14:05:18 -05:00
helpers.c bpf: introduce current->pid, tgid, uid, gid, comm accessors 2015-06-15 15:53:50 -07:00
Makefile ebpf: remove kernel test stubs 2015-03-01 14:05:18 -05:00
syscall.c ebpf: fix fd refcount leaks related to maps in bpf syscall 2015-09-09 12:39:34 -07:00
verifier.c bpf: fix bpf_perf_event_read() loop upper bound 2015-08-12 16:42:50 -07:00