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-next 0/4] Fix global subprog PTR_TO_CTX arg handling
Date: Tue, 13 Feb 2024 18:39:25 +0200	[thread overview]
Message-ID: <8fa4a4ed5957f32b20eb12fac8e590c61502cd6b.camel@gmail.com> (raw)
In-Reply-To: <20240212233221.2575350-1-andrii@kernel.org>

On Mon, 2024-02-12 at 15:32 -0800, Andrii Nakryiko wrote:
> Fix confusing and incorrect inference of PTR_TO_CTX argument type in BPF
> global subprogs. For some program types (iters, tracepoint, any program type
> that doesn't have fixed named "canonical" context type) when user uses (in
> a correct and valid way) a pointer argument to user-defined anonymous struct
> type, verifier will incorrectly assume that it has to be PTR_TO_CTX argument.
> While it should be just a PTR_TO_MEM argument with allowed size calculated
> from user-provided (even if anonymous) struct.
> 
> This did come up in practice and was very confusing to users, so let's prevent
> this going forward. We had to do a slight refactoring of
> btf_get_prog_ctx_type() to make it easy to support a special s390x KPROBE use
> cases. See details in respective patches.
> 
> v1->v2:
>   - special-case typedef bpf_user_pt_regs_t handling for KPROBE programs,
>     fixing s390x after changes in patch #2.
> 
> Andrii Nakryiko (4):
>   bpf: simplify btf_get_prog_ctx_type() into btf_is_prog_ctx_type()
>   bpf: handle bpf_user_pt_regs_t typedef explicitly for PTR_TO_CTX
>     global arg
>   bpf: don't infer PTR_TO_CTX for programs with unnamed context type
>   selftests/bpf: add anonymous user struct as global subprog arg test
> 
>  include/linux/btf.h                           | 17 ++++---
>  kernel/bpf/btf.c                              | 45 +++++++++++++------
>  kernel/bpf/verifier.c                         |  2 +-
>  .../bpf/progs/test_global_func_ctx_args.c     | 19 ++++++++
>  .../bpf/progs/verifier_global_subprogs.c      | 29 ++++++++++++
>  5 files changed, 88 insertions(+), 24 deletions(-)
> 

I have a nit for patch #2 but that might be not important.

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



  parent reply	other threads:[~2024-02-13 16:39 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-12 23:32 [PATCH v2 bpf-next 0/4] Fix global subprog PTR_TO_CTX arg handling Andrii Nakryiko
2024-02-12 23:32 ` [PATCH v2 bpf-next 1/4] bpf: simplify btf_get_prog_ctx_type() into btf_is_prog_ctx_type() Andrii Nakryiko
2024-02-12 23:32 ` [PATCH v2 bpf-next 2/4] bpf: handle bpf_user_pt_regs_t typedef explicitly for PTR_TO_CTX global arg Andrii Nakryiko
2024-02-13 16:40   ` Eduard Zingerman
2024-02-13 17:02     ` Andrii Nakryiko
2024-02-13 17:08       ` Eduard Zingerman
2024-02-13 18:12         ` Andrii Nakryiko
2024-02-13 18:48           ` Eduard Zingerman
2024-02-13 18:59             ` Andrii Nakryiko
2024-02-12 23:32 ` [PATCH v2 bpf-next 3/4] bpf: don't infer PTR_TO_CTX for programs with unnamed context type Andrii Nakryiko
2024-02-12 23:32 ` [PATCH v2 bpf-next 4/4] selftests/bpf: add anonymous user struct as global subprog arg test Andrii Nakryiko
2024-02-13 12:51 ` [PATCH v2 bpf-next 0/4] Fix global subprog PTR_TO_CTX arg handling Jiri Olsa
2024-02-13 16:39 ` Eduard Zingerman [this message]
2024-02-14  2:50 ` patchwork-bot+netdevbpf

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=8fa4a4ed5957f32b20eb12fac8e590c61502cd6b.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