diff mbox series

[bpf-next,1/2] selftests/bpf: Add reproducer for decl_tag in func_proto argument

Message ID 20221123035422.872531-1-sdf@google.com (mailing list archive)
State Accepted
Commit 8e898aaa733eca61393fc036c8a4b5834fee5dd3
Delegated to: BPF
Headers show
Series [bpf-next,1/2] selftests/bpf: Add reproducer for decl_tag in func_proto argument | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for bpf-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 4 maintainers not CCed: linux-kselftest@vger.kernel.org shuah@kernel.org mykolal@fb.com eddyz87@gmail.com
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch warning WARNING: line length of 97 exceeds 80 columns
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
bpf/vmtest-bpf-next-VM_Test-21 fail Logs for test_progs_no_alu32 on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-36 success Logs for test_verifier on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-16 fail Logs for test_progs on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-26 success Logs for test_progs_no_alu32_parallel on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-31 success Logs for test_progs_parallel on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-11 success Logs for test_maps on s390x with gcc
bpf/vmtest-bpf-next-PR success PR summary
bpf/vmtest-bpf-next-VM_Test-1 success Logs for ShellCheck
bpf/vmtest-bpf-next-VM_Test-7 success Logs for llvm-toolchain
bpf/vmtest-bpf-next-VM_Test-8 success Logs for set-matrix
bpf/vmtest-bpf-next-VM_Test-6 success Logs for build for x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-2 success Logs for build for aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-3 success Logs for build for aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-5 success Logs for build for x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-4 success Logs for build for s390x with gcc
bpf/vmtest-bpf-next-VM_Test-25 success Logs for test_progs_no_alu32_parallel on aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-34 success Logs for test_verifier on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-35 success Logs for test_verifier on aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-37 success Logs for test_verifier on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-38 success Logs for test_verifier on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-9 success Logs for test_maps on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-10 success Logs for test_maps on aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-12 success Logs for test_maps on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-13 success Logs for test_maps on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-14 success Logs for test_progs on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-15 success Logs for test_progs on aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-17 success Logs for test_progs on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-18 success Logs for test_progs on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-19 fail Logs for test_progs_no_alu32 on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-20 success Logs for test_progs_no_alu32 on aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-22 success Logs for test_progs_no_alu32 on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-23 success Logs for test_progs_no_alu32 on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-24 success Logs for test_progs_no_alu32_parallel on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-27 success Logs for test_progs_no_alu32_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-28 success Logs for test_progs_no_alu32_parallel on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-29 success Logs for test_progs_parallel on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-30 success Logs for test_progs_parallel on aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-32 success Logs for test_progs_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-33 success Logs for test_progs_parallel on x86_64 with llvm-16

Commit Message

Stanislav Fomichev Nov. 23, 2022, 3:54 a.m. UTC
It should trigger a WARN_ON_ONCE in btf_type_id_size.

    RIP: 0010:btf_type_id_size+0x8bd/0x940 kernel/bpf/btf.c:1952
    btf_func_proto_check kernel/bpf/btf.c:4506 [inline]
    btf_check_all_types kernel/bpf/btf.c:4734 [inline]
    btf_parse_type_sec+0x1175/0x1980 kernel/bpf/btf.c:4763
    btf_parse kernel/bpf/btf.c:5042 [inline]
    btf_new_fd+0x65a/0xb00 kernel/bpf/btf.c:6709
    bpf_btf_load+0x6f/0x90 kernel/bpf/syscall.c:4342
    __sys_bpf+0x50a/0x6c0 kernel/bpf/syscall.c:5034
    __do_sys_bpf kernel/bpf/syscall.c:5093 [inline]
    __se_sys_bpf kernel/bpf/syscall.c:5091 [inline]
    __x64_sys_bpf+0x7c/0x90 kernel/bpf/syscall.c:5091
    do_syscall_64+0x54/0x70 arch/x86/entry/common.c:48

Signed-off-by: Stanislav Fomichev <sdf@google.com>
---
 tools/testing/selftests/bpf/prog_tests/btf.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

Comments

Yonghong Song Nov. 23, 2022, 7:40 p.m. UTC | #1
On 11/22/22 7:54 PM, Stanislav Fomichev wrote:
> It should trigger a WARN_ON_ONCE in btf_type_id_size.
> 
>      RIP: 0010:btf_type_id_size+0x8bd/0x940 kernel/bpf/btf.c:1952
>      btf_func_proto_check kernel/bpf/btf.c:4506 [inline]
>      btf_check_all_types kernel/bpf/btf.c:4734 [inline]
>      btf_parse_type_sec+0x1175/0x1980 kernel/bpf/btf.c:4763
>      btf_parse kernel/bpf/btf.c:5042 [inline]
>      btf_new_fd+0x65a/0xb00 kernel/bpf/btf.c:6709
>      bpf_btf_load+0x6f/0x90 kernel/bpf/syscall.c:4342
>      __sys_bpf+0x50a/0x6c0 kernel/bpf/syscall.c:5034
>      __do_sys_bpf kernel/bpf/syscall.c:5093 [inline]
>      __se_sys_bpf kernel/bpf/syscall.c:5091 [inline]
>      __x64_sys_bpf+0x7c/0x90 kernel/bpf/syscall.c:5091
>      do_syscall_64+0x54/0x70 arch/x86/entry/common.c:48
> 
> Signed-off-by: Stanislav Fomichev <sdf@google.com>

Acked-by: Yonghong Song <yhs@fb.com>

> ---
>   tools/testing/selftests/bpf/prog_tests/btf.c | 14 ++++++++++++++
>   1 file changed, 14 insertions(+)
> 
> diff --git a/tools/testing/selftests/bpf/prog_tests/btf.c b/tools/testing/selftests/bpf/prog_tests/btf.c
> index 95a2b80f0d17..de1b5b9eb93a 100644
> --- a/tools/testing/selftests/bpf/prog_tests/btf.c
> +++ b/tools/testing/selftests/bpf/prog_tests/btf.c
> @@ -3948,6 +3948,20 @@ static struct btf_raw_test raw_tests[] = {
>   	.btf_load_err = true,
>   	.err_str = "Invalid return type",
>   },
> +{
> +	.descr = "decl_tag test #17, func proto, argument",
> +	.raw_types = {
> +		BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_DECL_TAG, 0, 0), 4), (-1),	/* [1] */
> +		BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_PTR, 0, 0), 0), /* [2] */
> +		BTF_FUNC_PROTO_ENC(0, 1),			/* [3] */
> +			BTF_FUNC_PROTO_ARG_ENC(NAME_TBD, 1),
> +		BTF_VAR_ENC(NAME_TBD, 2, 0),			/* [4] */
> +		BTF_END_RAW,
> +	},
> +	BTF_STR_SEC("\0local\0tag1\0var"),
> +	.btf_load_err = true,
> +	.err_str = "Invalid arg#1",
> +},
>   {
>   	.descr = "type_tag test #1",
>   	.raw_types = {
patchwork-bot+netdevbpf@kernel.org Nov. 24, 2022, midnight UTC | #2
Hello:

This series was applied to bpf/bpf-next.git (master)
by Daniel Borkmann <daniel@iogearbox.net>:

On Tue, 22 Nov 2022 19:54:21 -0800 you wrote:
> It should trigger a WARN_ON_ONCE in btf_type_id_size.
> 
>     RIP: 0010:btf_type_id_size+0x8bd/0x940 kernel/bpf/btf.c:1952
>     btf_func_proto_check kernel/bpf/btf.c:4506 [inline]
>     btf_check_all_types kernel/bpf/btf.c:4734 [inline]
>     btf_parse_type_sec+0x1175/0x1980 kernel/bpf/btf.c:4763
>     btf_parse kernel/bpf/btf.c:5042 [inline]
>     btf_new_fd+0x65a/0xb00 kernel/bpf/btf.c:6709
>     bpf_btf_load+0x6f/0x90 kernel/bpf/syscall.c:4342
>     __sys_bpf+0x50a/0x6c0 kernel/bpf/syscall.c:5034
>     __do_sys_bpf kernel/bpf/syscall.c:5093 [inline]
>     __se_sys_bpf kernel/bpf/syscall.c:5091 [inline]
>     __x64_sys_bpf+0x7c/0x90 kernel/bpf/syscall.c:5091
>     do_syscall_64+0x54/0x70 arch/x86/entry/common.c:48
> 
> [...]

Here is the summary with links:
  - [bpf-next,1/2] selftests/bpf: Add reproducer for decl_tag in func_proto argument
    https://git.kernel.org/bpf/bpf-next/c/8e898aaa733e
  - [bpf-next,2/2] bpf: prevent decl_tag from being referenced in func_proto arg
    https://git.kernel.org/bpf/bpf-next/c/f17472d45996

You are awesome, thank you!
diff mbox series

Patch

diff --git a/tools/testing/selftests/bpf/prog_tests/btf.c b/tools/testing/selftests/bpf/prog_tests/btf.c
index 95a2b80f0d17..de1b5b9eb93a 100644
--- a/tools/testing/selftests/bpf/prog_tests/btf.c
+++ b/tools/testing/selftests/bpf/prog_tests/btf.c
@@ -3948,6 +3948,20 @@  static struct btf_raw_test raw_tests[] = {
 	.btf_load_err = true,
 	.err_str = "Invalid return type",
 },
+{
+	.descr = "decl_tag test #17, func proto, argument",
+	.raw_types = {
+		BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_DECL_TAG, 0, 0), 4), (-1),	/* [1] */
+		BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_PTR, 0, 0), 0), /* [2] */
+		BTF_FUNC_PROTO_ENC(0, 1),			/* [3] */
+			BTF_FUNC_PROTO_ARG_ENC(NAME_TBD, 1),
+		BTF_VAR_ENC(NAME_TBD, 2, 0),			/* [4] */
+		BTF_END_RAW,
+	},
+	BTF_STR_SEC("\0local\0tag1\0var"),
+	.btf_load_err = true,
+	.err_str = "Invalid arg#1",
+},
 {
 	.descr = "type_tag test #1",
 	.raw_types = {