bpf: handle pseudo BPF_LD_IMM64 insn
authorAlexei Starovoitov <ast@plumgrid.com>
Fri, 26 Sep 2014 07:17:04 +0000 (00:17 -0700)
committerDavid S. Miller <davem@davemloft.net>
Fri, 26 Sep 2014 19:05:15 +0000 (15:05 -0400)
commit0246e64d9a5fcd4805198de59b9b5cf1f974eb41
tree3a7b78d9f3dcfb255d0ac9ce5350cef1e195eddf
parentcbd357008604925355ae7b54a09137dabb81b580
bpf: handle pseudo BPF_LD_IMM64 insn

eBPF programs passed from userspace are using pseudo BPF_LD_IMM64 instructions
to refer to process-local map_fd. Scan the program for such instructions and
if FDs are valid, convert them to 'struct bpf_map' pointers which will be used
by verifier to check access to maps in bpf_map_lookup/update() calls.
If program passes verifier, convert pseudo BPF_LD_IMM64 into generic by dropping
BPF_PSEUDO_MAP_FD flag.

Note that eBPF interpreter is generic and knows nothing about pseudo insns.

Signed-off-by: Alexei Starovoitov <ast@plumgrid.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/filter.h
kernel/bpf/verifier.c