All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Borkmann <daniel@iogearbox.net>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>, davem@davemloft.net
Cc: andrii@kernel.org, john.fastabend@gmail.com, bpf@vger.kernel.org,
	kernel-team@fb.com
Subject: Re: [PATCH v6 bpf-next 00/21] bpf: syscall program, FD array, loader program, light skeleton.
Date: Tue, 18 May 2021 21:54:31 +0200	[thread overview]
Message-ID: <4a843738-4eb1-d993-6b64-7f36144d2456@iogearbox.net> (raw)
In-Reply-To: <20210514003623.28033-1-alexei.starovoitov@gmail.com>

On 5/14/21 2:36 AM, Alexei Starovoitov wrote:
[...]
> This is a first step towards signed bpf programs and the third approach of that kind.
> The first approach was to bring libbpf into the kernel as a user-mode-driver.
> The second approach was to invent a new file format and let kernel execute
> that format as a sequence of syscalls that create maps and load programs.
> This third approach is using new type of bpf program instead of inventing file format.
> 1st and 2nd approaches had too many downsides comparing to this 3rd and were discarded
> after months of work.
> 
> To make it work the following new concepts are introduced:
> 1. syscall bpf program type
> A kind of bpf program that can do sys_bpf and sys_close syscalls.
> It can only execute in user context.
> 
> 2. FD array or FD index.
> Traditionally BPF instructions are patched with FDs.
> What it means that maps has to be created first and then instructions modified
> which breaks signature verification if the program is signed.
> Instead of patching each instruction with FD patch it with an index into array of FDs.
> That makes the program signature stable if it uses maps.
> 
> 3. loader program that is generated as "strace of libbpf".
> When libbpf is loading bpf_file.o it does a bunch of sys_bpf() syscalls to
> load BTF, create maps, populate maps and finally load programs.
> Instead of actually doing the syscalls generate a trace of what libbpf
> would have done and represent it as the "loader program".
> The "loader program" consists of single map and single bpf program that
> does those syscalls.
> Executing such "loader program" via bpf_prog_test_run() command will
> replay the sequence of syscalls that libbpf would have done which will result
> the same maps created and programs loaded as specified in the elf file.
> The "loader program" removes libelf and majority of libbpf dependency from
> program loading process.

More of a general question since afaik from prior discussion it didn't came up.
I think conceptually, it's rather weird to only being able to execute the loader
program which is later also supposed to do signing through the BPF_PROG_TEST_RUN
aka our _testing_ infrastructure. Given it's not mentioned in future steps, is
there anything planned before it becomes uapi and fixed part of skeleton (in
particular the libbpf bpf_load_and_run() helper officially calling into the
skel_sys_bpf(BPF_PROG_TEST_RUN, &attr, sizeof(attr))) on this regard or is the
BPF_PROG_TEST_RUN really supposed to be the /main/ interface going forward;
what's the plan on this?

> 4. light skeleton
> Instead of embedding the whole elf file into skeleton and using libbpf
> to parse it later generate a loader program and embed it into "light skeleton".
> Such skeleton can load the same set of elf files, but it doesn't need
> libbpf and libelf to do that. It only needs few sys_bpf wrappers.
> 
> Future steps:
> - support CO-RE in the kernel. This patch set is already too big,
> so that critical feature is left for the next step.
> - generate light skeleton in golang to allow such users use BTF and
> all other features provided by libbpf
> - generate light skeleton for kernel, so that bpf programs can be embeded
> in the kernel module. The UMD usage in bpf_preload will be replaced with
> such skeleton, so bpf_preload would become a standard kernel module
> without user space dependency.
> - finally do the signing of the loader program.
> 
> The patches are work in progress with few rough edges.

Thanks a lot,
Daniel

  parent reply	other threads:[~2021-05-18 19:54 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-14  0:36 [PATCH v6 bpf-next 00/21] bpf: syscall program, FD array, loader program, light skeleton Alexei Starovoitov
2021-05-14  0:36 ` [PATCH v6 bpf-next 01/21] bpf: Introduce bpf_sys_bpf() helper and program type Alexei Starovoitov
2021-05-14  0:36 ` [PATCH v6 bpf-next 02/21] bpf: Introduce bpfptr_t user/kernel pointer Alexei Starovoitov
2021-05-14  0:36 ` [PATCH v6 bpf-next 03/21] bpf: Prepare bpf syscall to be used from kernel and user space Alexei Starovoitov
2021-05-14  0:36 ` [PATCH v6 bpf-next 04/21] libbpf: Support for syscall program type Alexei Starovoitov
2021-05-14  0:36 ` [PATCH v6 bpf-next 05/21] selftests/bpf: Test " Alexei Starovoitov
2021-05-14  0:36 ` [PATCH v6 bpf-next 06/21] bpf: Make btf_load command to be bpfptr_t compatible Alexei Starovoitov
2021-05-14  0:36 ` [PATCH v6 bpf-next 07/21] selftests/bpf: Test for btf_load command Alexei Starovoitov
2021-05-14 18:12   ` Andrii Nakryiko
2021-05-14  0:36 ` [PATCH v6 bpf-next 08/21] bpf: Introduce fd_idx Alexei Starovoitov
2021-05-14  0:36 ` [PATCH v6 bpf-next 09/21] bpf: Add bpf_btf_find_by_name_kind() helper Alexei Starovoitov
2021-05-14  0:36 ` [PATCH v6 bpf-next 10/21] bpf: Add bpf_sys_close() helper Alexei Starovoitov
2021-05-14  0:36 ` [PATCH v6 bpf-next 11/21] libbpf: Change the order of data and text relocations Alexei Starovoitov
2021-05-14  0:36 ` [PATCH v6 bpf-next 12/21] libbpf: Add bpf_object pointer to kernel_supports() Alexei Starovoitov
2021-05-14  0:36 ` [PATCH v6 bpf-next 13/21] libbpf: Preliminary support for fd_idx Alexei Starovoitov
2021-05-14  0:36 ` [PATCH v6 bpf-next 14/21] libbpf: Generate loader program out of BPF ELF file Alexei Starovoitov
2021-06-11 20:22   ` Andrii Nakryiko
2021-07-20 20:51     ` Alexei Starovoitov
2021-07-20 21:10       ` Andrii Nakryiko
2021-05-14  0:36 ` [PATCH v6 bpf-next 15/21] libbpf: Cleanup temp FDs when intermediate sys_bpf fails Alexei Starovoitov
2021-05-14  0:36 ` [PATCH v6 bpf-next 16/21] libbpf: Introduce bpf_map__initial_value() Alexei Starovoitov
2021-05-14 18:02   ` Andrii Nakryiko
2021-05-14  0:36 ` [PATCH v6 bpf-next 17/21] bpftool: Use syscall/loader program in "prog load" and "gen skeleton" command Alexei Starovoitov
2021-05-14  0:36 ` [PATCH v6 bpf-next 18/21] selftests/bpf: Convert few tests to light skeleton Alexei Starovoitov
2021-05-14  0:36 ` [PATCH v6 bpf-next 19/21] selftests/bpf: Convert atomics test " Alexei Starovoitov
2021-05-14  0:36 ` [PATCH v6 bpf-next 20/21] selftests/bpf: Convert test printk to use rodata Alexei Starovoitov
2021-05-14 18:15   ` Andrii Nakryiko
2021-05-14  0:36 ` [PATCH v6 bpf-next 21/21] selftests/bpf: Convert test trace_printk to lskel Alexei Starovoitov
2021-05-14 18:16 ` [PATCH v6 bpf-next 00/21] bpf: syscall program, FD array, loader program, light skeleton Andrii Nakryiko
2021-05-18 19:54 ` Daniel Borkmann [this message]
2021-05-18 21:17   ` Alexei Starovoitov
2021-05-18 23:04     ` Daniel Borkmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4a843738-4eb1-d993-6b64-7f36144d2456@iogearbox.net \
    --to=daniel@iogearbox.net \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=davem@davemloft.net \
    --cc=john.fastabend@gmail.com \
    --cc=kernel-team@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.