BPF List
 help / color / mirror / Atom feed
From: Alan Maguire <alan.maguire@oracle.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>, bpf@vger.kernel.org
Cc: daniel@iogearbox.net, andrii@kernel.org, eddyz87@gmail.com,
	memxor@gmail.com
Subject: Re: [PATCH bpf-next 07/14] bpf: Allow arguments without names in static functions in BTF
Date: Thu, 1 Oct 2026 22:14:38 +0100	[thread overview]
Message-ID: <4445c0a9-4f5d-45da-999b-8a6c00526aed@oracle.com> (raw)
In-Reply-To: <20260930193127.2181684-8-alexei.starovoitov@gmail.com>

On 30/09/2026 20:31, Alexei Starovoitov wrote:
> From: Alexei Starovoitov <ast@kernel.org>
> 
> Some static functions in BTF of a Rust program have arguments without
> names:
> 
>   [71] FUNC_PROTO '(anon)' ret_type_id=0 vlen=1
>           '(anon)' type_id=72
>   [81] FUNC 'unwrap_failed' type_id=71 linkage=static
> 
> and the kernel rejects such BTF with "Invalid arg#1". It's 5 of 25
> static functions in scx_cosmos and 6 of 24 in scx_simple.
> 
> The verifier looks at types of the arguments. The names are printed only,
> as "(anon)" when there is none. Allow such static FUNC. Global functions
> are checked as before.
> 
> The test "func (Some arg has no name)" in prog_tests/btf.c has a static
> function. Make it global to keep the check.
> 
> Signed-off-by: Alexei Starovoitov <ast@kernel.org>

Acked-by: Alan Maguire <alan.maguire@oracle.com>

> ---
>  kernel/bpf/btf.c                             | 4 ++++
>  tools/testing/selftests/bpf/prog_tests/btf.c | 5 +++--
>  2 files changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
> index d27af5d8e495..c9d4b709380c 100644
> --- a/kernel/bpf/btf.c
> +++ b/kernel/bpf/btf.c
> @@ -5752,6 +5752,10 @@ static int btf_func_check(struct btf_verifier_env *env,
>  		return -EINVAL;
>  	}
>  
> +	/* Rust leaves out names of some arguments of static functions */
> +	if (btf_func_linkage(t) == BTF_FUNC_STATIC)
> +		return 0;
> +
>  	args = (const struct btf_param *)(proto_type + 1);
>  	nr_args = btf_type_vlen(proto_type);
>  	for (i = 0; i < nr_args; i++) {


> diff --git a/tools/testing/selftests/bpf/prog_tests/btf.c b/tools/testing/selftests/bpf/prog_tests/btf.c
> index 207341f4bd99..21fdeeb23405 100644
> --- a/tools/testing/selftests/bpf/prog_tests/btf.c
> +++ b/tools/testing/selftests/bpf/prog_tests/btf.c
> @@ -2793,7 +2793,7 @@ static struct btf_raw_test raw_tests[] = {
>  },
>  
>  {
> -	.descr = "func (Some arg has no name)",
> +	.descr = "func (Some arg of global func has no name)",
>  	.raw_types = {
>  		BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4),	/* [1] */
>  		BTF_TYPE_INT_ENC(0, 0, 0, 32, 4),		/* [2] */
> @@ -2802,7 +2802,8 @@ static struct btf_raw_test raw_tests[] = {
>  			BTF_FUNC_PROTO_ARG_ENC(NAME_TBD, 1),
>  			BTF_FUNC_PROTO_ARG_ENC(0, 2),
>  		/* void func(int a, unsigned int) */
> -		BTF_FUNC_ENC(NAME_TBD, 3),			/* [4] */
> +		BTF_TYPE_ENC(NAME_TBD,				/* [4] */
> +			     BTF_INFO_ENC(BTF_KIND_FUNC, 0, BTF_FUNC_GLOBAL), 3),
>  		BTF_END_RAW,
>  	},
>  	.str_sec = "\0a\0func",


  reply	other threads:[~2026-10-01 21:15 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-30 19:31 [PATCH bpf-next 00/14] bpf: Support programs compiled by rust-bpf Alexei Starovoitov
2026-09-30 19:31 ` [PATCH bpf-next 01/14] bpf: Allow bitwise ops, shifts and mul/div on pointers with CAP_PERFMON Alexei Starovoitov
2026-09-30 19:31 ` [PATCH bpf-next 02/14] selftests/bpf: Add tests for ALU " Alexei Starovoitov
2026-09-30 19:31 ` [PATCH bpf-next 03/14] bpf: Treat load and store through a number as arena access Alexei Starovoitov
2026-09-30 19:31 ` [PATCH bpf-next 04/14] selftests/bpf: Add tests for arena access through numbers Alexei Starovoitov
2026-09-30 19:48   ` sashiko-bot
2026-09-30 20:22   ` bot+bpf-ci
2026-09-30 19:31 ` [PATCH bpf-next 05/14] bpf: Allow names of Rust types and functions in BTF Alexei Starovoitov
2026-09-30 20:22   ` bot+bpf-ci
2026-10-01 17:42   ` Alan Maguire
2026-10-02 12:24     ` Alexei Starovoitov
2026-10-02 13:38       ` Alan Maguire
2026-09-30 19:31 ` [PATCH bpf-next 06/14] selftests/bpf: Add tests for " Alexei Starovoitov
2026-09-30 20:22   ` bot+bpf-ci
2026-09-30 19:31 ` [PATCH bpf-next 07/14] bpf: Allow arguments without names in static " Alexei Starovoitov
2026-10-01 21:14   ` Alan Maguire [this message]
2026-09-30 19:31 ` [PATCH bpf-next 08/14] selftests/bpf: Add test for arguments without names in static functions Alexei Starovoitov
2026-10-01 21:22   ` Alan Maguire
2026-09-30 19:31 ` [PATCH bpf-next 09/14] bpf: Allow a variable in DATASEC that is smaller than its type Alexei Starovoitov
2026-09-30 19:47   ` sashiko-bot
2026-09-30 19:31 ` [PATCH bpf-next 10/14] selftests/bpf: Add tests for a variable " Alexei Starovoitov
2026-09-30 19:31 ` [PATCH bpf-next 11/14] libbpf: Keep global data in arena when the object has .arena.data Alexei Starovoitov
2026-09-30 19:46   ` sashiko-bot
2026-09-30 20:22   ` bot+bpf-ci
2026-09-30 19:31 ` [PATCH bpf-next 12/14] libbpf: Keep format strings of bpf_printk() in .rodata.str Alexei Starovoitov
2026-09-30 20:22   ` bot+bpf-ci
2026-09-30 19:31 ` [PATCH bpf-next 13/14] selftests/bpf: Add test for global data in arena Alexei Starovoitov
2026-09-30 20:22   ` bot+bpf-ci
2026-09-30 19:31 ` [PATCH bpf-next 14/14] selftests/bpf: Add test for global data of a program in Rust Alexei Starovoitov
2026-09-30 19:53   ` sashiko-bot
2026-09-30 20:22   ` bot+bpf-ci

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=4445c0a9-4f5d-45da-999b-8a6c00526aed@oracle.com \
    --to=alan.maguire@oracle.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=memxor@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox