From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752835AbbIKNjZ (ORCPT ); Fri, 11 Sep 2015 09:39:25 -0400 Received: from www62.your-server.de ([213.133.104.62]:39531 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751795AbbIKNjX (ORCPT ); Fri, 11 Sep 2015 09:39:23 -0400 Message-ID: <55F2D982.8010406@iogearbox.net> Date: Fri, 11 Sep 2015 15:39:14 +0200 From: Daniel Borkmann User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Tycho Andersen , Kees Cook , Alexei Starovoitov CC: "David S. Miller" , Will Drewry , Oleg Nesterov , Andy Lutomirski , Pavel Emelyanov , "Serge E. Hallyn" , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-api@vger.kernel.org Subject: Re: [PATCH v2 3/5] ebpf: add a way to dump an eBPF program References: <1441930862-14347-1-git-send-email-tycho.andersen@canonical.com> <1441930862-14347-4-git-send-email-tycho.andersen@canonical.com> In-Reply-To: <1441930862-14347-4-git-send-email-tycho.andersen@canonical.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Authenticated-Sender: daniel@iogearbox.net Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/11/2015 02:21 AM, Tycho Andersen wrote: > This commit adds a way to dump eBPF programs. The initial implementation > doesn't support maps, and therefore only allows dumping seccomp ebpf > programs which themselves don't currently support maps. > > v2: don't export a prog_id for the filter > > Signed-off-by: Tycho Andersen > CC: Kees Cook > CC: Will Drewry > CC: Oleg Nesterov > CC: Andy Lutomirski > CC: Pavel Emelyanov > CC: Serge E. Hallyn > CC: Alexei Starovoitov > CC: Daniel Borkmann [...] > diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c > index dc9b464..58ae9f4 100644 > --- a/kernel/bpf/syscall.c > +++ b/kernel/bpf/syscall.c > @@ -586,6 +586,44 @@ free_prog: > return err; > } > > +static int bpf_prog_dump(union bpf_attr *attr, union bpf_attr __user *uattr) > +{ > + int ufd = attr->prog_fd; > + struct fd f = fdget(ufd); > + struct bpf_prog *prog; > + int ret = -EINVAL; > + > + prog = get_prog(f); > + if (IS_ERR(prog)) > + return PTR_ERR(prog); > + > + /* For now, let's refuse to dump anything that isn't a seccomp program. > + * Other program types have support for maps, which our current dump > + * code doesn't support. > + */ > + if (prog->type != BPF_PROG_TYPE_SECCOMP) > + goto out; Yep, also when you start adding helper calls (next to map objects) you'd need to undo kernel pointers that the verifier sets here.