linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yafang Shao <laoar.shao@gmail.com>
To: KaFai Wan <kafai.wan@linux.dev>
Cc: ast@kernel.org, daniel@iogearbox.net, john.fastabend@gmail.com,
	 andrii@kernel.org, martin.lau@linux.dev, eddyz87@gmail.com,
	song@kernel.org,  yonghong.song@linux.dev, kpsingh@kernel.org,
	sdf@fomichev.me,  haoluo@google.com, jolsa@kernel.org,
	mykolal@fb.com, shuah@kernel.org,  linux-kernel@vger.kernel.org,
	bpf@vger.kernel.org,  linux-kselftest@vger.kernel.org,
	leon.hwang@linux.dev
Subject: Re: [PATCH bpf-next v3 1/4] bpf: Show precise rejected function when attaching fexit/fmod_ret to __noreturn functions
Date: Wed, 23 Jul 2025 19:37:16 +0800	[thread overview]
Message-ID: <CALOAHbAbZtdY8hCbFAjTBDjzCkeNFMd2qWzHBG-fAbOsFpqmpA@mail.gmail.com> (raw)
In-Reply-To: <20250722153434.20571-2-kafai.wan@linux.dev>

On Tue, Jul 22, 2025 at 11:35 PM KaFai Wan <kafai.wan@linux.dev> wrote:
>
> With this change, we know the precise rejected function name when
> attaching fexit/fmod_ret to __noreturn functions from log.
>
> $ ./fexit
> libbpf: prog 'fexit': BPF program load failed: -EINVAL
> libbpf: prog 'fexit': -- BEGIN PROG LOAD LOG --
> Attaching fexit/fmod_ret to __noreturn function 'do_exit' is rejected.
>
> Suggested-by: Leon Hwang <leon.hwang@linux.dev>
> Signed-off-by: KaFai Wan <kafai.wan@linux.dev>

Acked-by: Yafang Shao <laoar.shao@gmail.com>

> ---
>  kernel/bpf/verifier.c                               | 3 ++-
>  tools/testing/selftests/bpf/progs/fexit_noreturns.c | 2 +-
>  2 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> index e2fcea860755..00d287814f12 100644
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c
> @@ -23946,7 +23946,8 @@ static int check_attach_btf_id(struct bpf_verifier_env *env)
>         } else if ((prog->expected_attach_type == BPF_TRACE_FEXIT ||
>                    prog->expected_attach_type == BPF_MODIFY_RETURN) &&
>                    btf_id_set_contains(&noreturn_deny, btf_id)) {
> -               verbose(env, "Attaching fexit/fmod_ret to __noreturn functions is rejected.\n");
> +               verbose(env, "Attaching fexit/fmod_ret to __noreturn function '%s' is rejected.\n",
> +                       tgt_info.tgt_name);
>                 return -EINVAL;
>         }
>
> diff --git a/tools/testing/selftests/bpf/progs/fexit_noreturns.c b/tools/testing/selftests/bpf/progs/fexit_noreturns.c
> index 54654539f550..b1c33d958ae2 100644
> --- a/tools/testing/selftests/bpf/progs/fexit_noreturns.c
> +++ b/tools/testing/selftests/bpf/progs/fexit_noreturns.c
> @@ -8,7 +8,7 @@
>  char _license[] SEC("license") = "GPL";
>
>  SEC("fexit/do_exit")
> -__failure __msg("Attaching fexit/fmod_ret to __noreturn functions is rejected.")
> +__failure __msg("Attaching fexit/fmod_ret to __noreturn function 'do_exit' is rejected.")
>  int BPF_PROG(noreturns)
>  {
>         return 0;
> --
> 2.43.0
>


-- 
Regards
Yafang

  reply	other threads:[~2025-07-23 11:37 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-22 15:34 [PATCH bpf-next v3 0/4] bpf: Show precise rejected function when attaching to __noreturn and deny list functions KaFai Wan
2025-07-22 15:34 ` [PATCH bpf-next v3 1/4] bpf: Show precise rejected function when attaching fexit/fmod_ret to __noreturn functions KaFai Wan
2025-07-23 11:37   ` Yafang Shao [this message]
2025-07-23 16:36   ` Yonghong Song
2025-07-22 15:34 ` [PATCH bpf-next v3 2/4] bpf: Add log for attaching tracing programs to functions in deny list KaFai Wan
2025-07-23 11:37   ` Yafang Shao
2025-07-23 16:37   ` Yonghong Song
2025-07-22 15:34 ` [PATCH bpf-next v3 3/4] selftests/bpf: Add selftest " KaFai Wan
2025-07-23 16:42   ` Yonghong Song
2025-07-24 11:05     ` KaFai Wan
2025-07-22 15:34 ` [PATCH bpf-next v3 4/4] selftests/bpf: Migrate fexit_noreturns case into tracing_failure test suite KaFai Wan
2025-07-23 16:43   ` Yonghong Song

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=CALOAHbAbZtdY8hCbFAjTBDjzCkeNFMd2qWzHBG-fAbOsFpqmpA@mail.gmail.com \
    --to=laoar.shao@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kafai.wan@linux.dev \
    --cc=kpsingh@kernel.org \
    --cc=leon.hwang@linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=mykolal@fb.com \
    --cc=sdf@fomichev.me \
    --cc=shuah@kernel.org \
    --cc=song@kernel.org \
    --cc=yonghong.song@linux.dev \
    /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;
as well as URLs for NNTP newsgroup(s).