From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Borkmann Subject: Re: [PATCH RFC net-next 08/14] bpf: add eBPF verifier Date: Tue, 01 Jul 2014 10:05:04 +0200 Message-ID: <53B26BB0.90209@redhat.com> References: <1403913966-4927-1-git-send-email-ast@plumgrid.com> <1403913966-4927-9-git-send-email-ast@plumgrid.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1403913966-4927-9-git-send-email-ast-uqk4Ao+rVK5Wk0Htik3J/w@public.gmane.org> Sender: linux-api-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Alexei Starovoitov Cc: "David S. Miller" , Ingo Molnar , Linus Torvalds , Steven Rostedt , Chema Gonzalez , Eric Dumazet , Peter Zijlstra , Arnaldo Carvalho de Melo , Jiri Olsa , Thomas Gleixner , "H. Peter Anvin" , Andrew Morton , Kees Cook , linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-Id: linux-api@vger.kernel.org On 06/28/2014 02:06 AM, Alexei Starovoitov wrote: > Safety of eBPF programs is statically determined by the verifier, which detects: > - loops > - out of range jumps > - unreachable instructions > - invalid instructions > - uninitialized register access > - uninitialized stack access > - misaligned stack access > - out of range stack access > - invalid calling convention ... > More details in Documentation/networking/filter.txt > > Signed-off-by: Alexei Starovoitov > --- ... > kernel/bpf/verifier.c | 1431 +++++++++++++++++++++++++++++++++++ Looking at classic BPF verifier which checks safety of BPF user space programs, it's roughly 200 loc. :-/ > diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c > new file mode 100644 ... > +#define _(OP) ({ int ret = OP; if (ret < 0) return ret; }) ... > + _(get_map_info(env, map_id, &map)); ... > + _(size = bpf_size_to_bytes(bpf_size)); Nit: such macros should be removed, please.