BPF List
 help / color / mirror / Atom feed
From: Eduard Zingerman <eddyz87@gmail.com>
To: Andrii Nakryiko <andrii@kernel.org>,
	bpf@vger.kernel.org, ast@kernel.org,  daniel@iogearbox.net,
	martin.lau@kernel.org
Cc: kernel-team@meta.com
Subject: Re: [PATCH v2 bpf 0/5] Tighten up arg:ctx type enforcement
Date: Thu, 18 Jan 2024 21:49:53 +0200	[thread overview]
Message-ID: <781173a0f5e6eb383b03fc85dab3927ae88c52a5.camel@gmail.com> (raw)
In-Reply-To: <20240117223340.1733595-1-andrii@kernel.org>

On Wed, 2024-01-17 at 14:33 -0800, Andrii Nakryiko wrote:
> Follow up fixes for kernel-side and libbpf-side logic around handling arg:ctx
> (__arg_ctx) tagged arguments of BPF global subprogs.
> 
> Patch #1 adds libbpf feature detection of kernel-side __arg_ctx support to
> avoid unnecessary rewriting BTF types. With stricter kernel-side type
> enforcement this is now mandatory to avoid problems with using `struct
> bpf_user_pt_regs_t` instead of actual typedef. For __arg_ctx tagged arguments
> verifier is now ignoring superficial `bpf_user_pt_regs_t` typedef and resolves
> it down to the actual struct (pt_regs/user_pt_regs/etc, depending on
> architecture), but for old kernels without __arg_ctx support it's more
> backwards compatible for libbpf to use `struct bpf_user_pt_regs_t` rewrite
> which will work on wider range of kernels. So feature detection prevent libbpf
> accidentally breaking global subprogs on new kernels.
> 
> We also adjust selftests to do similar feature detection (much simpler, but
> potentially breaking due to kernel source code refactoring, which is fine for
> selftests), and skip tests expecting libbpf's BTF type rewrites.
> 
> Patch #2 is preparatory refactoring for patch #3 which adds type enforcement
> for arg:ctx tagged global subprog args. See the patch for specifics.
> 
> Patch #4 adds many new cases to ensure type logic works as expected.
> 
> Finally, patch #5 adds a relevant subset of kernel-side type checks to
> __arg_ctx cases that libbpf supports rewrite of. In libbpf's case, type
> violations are reported as warnings and BTF rewrite is not performed, which
> will eventually lead to BPF verifier complaining at program verification time.
> 
> Good care was taken to avoid conflicts between bpf and bpf-next tree (which
> has few follow up refactorings in the same code area). Once trees converge
> some of the code will be moved around a bit (and some will be deleted), but
> with no change to functionality or general shape of the code.
> 
> v1->v2:
>   - add user_pt_regs and user_regs_struct support for PERF_EVENT (CI);
>   - drop FEAT_ARG_CTX_TAG enum leftover from patch #1;
>   - fix warning about default: without break in the switch (CI).

I've read through patch-set and it seem to be ok,
checks match behavior described in patch #3 description.

Reviewed-by: Eduard Zingerman <eddyz87@gmail.com>

[...]

  parent reply	other threads:[~2024-01-18 19:49 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-17 22:33 [PATCH v2 bpf 0/5] Tighten up arg:ctx type enforcement Andrii Nakryiko
2024-01-17 22:33 ` [PATCH v2 bpf 1/5] libbpf: feature-detect arg:ctx tag support in kernel Andrii Nakryiko
2024-01-18 19:50   ` Eduard Zingerman
2024-01-19  0:43     ` Andrii Nakryiko
2024-01-19  0:46       ` Eduard Zingerman
2024-01-17 22:33 ` [PATCH v2 bpf 2/5] bpf: extract bpf_ctx_convert_map logic and make it more reusable Andrii Nakryiko
2024-01-17 22:33 ` [PATCH v2 bpf 3/5] bpf: enforce types for __arg_ctx-tagged arguments in global subprogs Andrii Nakryiko
2024-01-18 19:50   ` Eduard Zingerman
2024-01-19  0:50     ` Andrii Nakryiko
2024-01-17 22:33 ` [PATCH v2 bpf 4/5] selftests/bpf: add tests confirming type logic in kernel for __arg_ctx Andrii Nakryiko
2024-01-17 22:33 ` [PATCH v2 bpf 5/5] libbpf: warn on unexpected __arg_ctx type when rewriting BTF Andrii Nakryiko
2024-01-18 19:50   ` Eduard Zingerman
2024-01-19  0:53     ` Andrii Nakryiko
2024-01-19  1:00       ` Eduard Zingerman
2024-01-18 19:49 ` Eduard Zingerman [this message]
2024-01-18 19:53   ` [PATCH v2 bpf 0/5] Tighten up arg:ctx type enforcement Eduard Zingerman

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=781173a0f5e6eb383b03fc85dab3927ae88c52a5.camel@gmail.com \
    --to=eddyz87@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@meta.com \
    --cc=martin.lau@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox