diff mbox series

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

Message ID 20221015002444.2680969-1-sdf@google.com (mailing list archive)
State Accepted
Commit 35cc9d622e8cd45029a1656ab2c6817538bc4180
Delegated to: BPF
Headers show
Series [bpf-next,1/2] selftests/bpf: Add reproducer for decl_tag in func_proto return type | 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 3 maintainers not CCed: shuah@kernel.org linux-kselftest@vger.kernel.org mykolal@fb.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-4 success Logs for llvm-toolchain
bpf/vmtest-bpf-next-VM_Test-5 success Logs for set-matrix
bpf/vmtest-bpf-next-VM_Test-2 success Logs for build for x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-3 success Logs for build for x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-1 success Logs for build for s390x with gcc
bpf/vmtest-bpf-next-VM_Test-16 success Logs for test_verifier on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-7 success Logs for test_maps on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-8 success Logs for test_maps on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-13 success Logs for test_progs_no_alu32 on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-17 success Logs for test_verifier on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-10 success Logs for test_progs on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-11 success Logs for test_progs on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-14 success Logs for test_progs_no_alu32 on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-15 success Logs for test_verifier on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-6 success Logs for test_maps on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-12 success Logs for test_progs_no_alu32 on s390x with gcc
bpf/vmtest-bpf-next-PR success PR summary
bpf/vmtest-bpf-next-VM_Test-9 success Logs for test_progs on s390x with gcc

Commit Message

Stanislav Fomichev Oct. 15, 2022, 12:24 a.m. UTC
It should trigger a WARN_ON_ONCE in btf_type_id_size.

     btf_func_proto_check kernel/bpf/btf.c:4447 [inline]
     btf_check_all_types kernel/bpf/btf.c:4723 [inline]
     btf_parse_type_sec kernel/bpf/btf.c:4752 [inline]
     btf_parse kernel/bpf/btf.c:5026 [inline]
     btf_new_fd+0x1926/0x1e70 kernel/bpf/btf.c:6892
     bpf_btf_load kernel/bpf/syscall.c:4324 [inline]
     __sys_bpf+0xb7d/0x4cf0 kernel/bpf/syscall.c:5010
     __do_sys_bpf kernel/bpf/syscall.c:5069 [inline]
     __se_sys_bpf kernel/bpf/syscall.c:5067 [inline]
     __x64_sys_bpf+0x75/0xb0 kernel/bpf/syscall.c:5067
     do_syscall_x64 arch/x86/entry/common.c:50 [inline]
     do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
     entry_SYSCALL_64_after_hwframe+0x63/0xcd

Cc: Yonghong Song <yhs@fb.com>
Cc: Martin KaFai Lau <martin.lau@kernel.org>
Signed-off-by: Stanislav Fomichev <sdf@google.com>
---
 tools/testing/selftests/bpf/prog_tests/btf.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

Comments

Yonghong Song Oct. 17, 2022, 5:33 a.m. UTC | #1
On 10/14/22 5:24 PM, Stanislav Fomichev wrote:
> It should trigger a WARN_ON_ONCE in btf_type_id_size.
> 
>       btf_func_proto_check kernel/bpf/btf.c:4447 [inline]
>       btf_check_all_types kernel/bpf/btf.c:4723 [inline]
>       btf_parse_type_sec kernel/bpf/btf.c:4752 [inline]
>       btf_parse kernel/bpf/btf.c:5026 [inline]
>       btf_new_fd+0x1926/0x1e70 kernel/bpf/btf.c:6892
>       bpf_btf_load kernel/bpf/syscall.c:4324 [inline]
>       __sys_bpf+0xb7d/0x4cf0 kernel/bpf/syscall.c:5010
>       __do_sys_bpf kernel/bpf/syscall.c:5069 [inline]
>       __se_sys_bpf kernel/bpf/syscall.c:5067 [inline]
>       __x64_sys_bpf+0x75/0xb0 kernel/bpf/syscall.c:5067
>       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
>       do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
>       entry_SYSCALL_64_after_hwframe+0x63/0xcd
> 
> Cc: Yonghong Song <yhs@fb.com>
> Cc: Martin KaFai Lau <martin.lau@kernel.org>
> Signed-off-by: Stanislav Fomichev <sdf@google.com>

Acked-by: Yonghong Song <yhs@fb.com>
patchwork-bot+netdevbpf@kernel.org Oct. 17, 2022, 6:30 p.m. UTC | #2
Hello:

This series was applied to bpf/bpf.git (master)
by Martin KaFai Lau <martin.lau@kernel.org>:

On Fri, 14 Oct 2022 17:24:43 -0700 you wrote:
> It should trigger a WARN_ON_ONCE in btf_type_id_size.
> 
>      btf_func_proto_check kernel/bpf/btf.c:4447 [inline]
>      btf_check_all_types kernel/bpf/btf.c:4723 [inline]
>      btf_parse_type_sec kernel/bpf/btf.c:4752 [inline]
>      btf_parse kernel/bpf/btf.c:5026 [inline]
>      btf_new_fd+0x1926/0x1e70 kernel/bpf/btf.c:6892
>      bpf_btf_load kernel/bpf/syscall.c:4324 [inline]
>      __sys_bpf+0xb7d/0x4cf0 kernel/bpf/syscall.c:5010
>      __do_sys_bpf kernel/bpf/syscall.c:5069 [inline]
>      __se_sys_bpf kernel/bpf/syscall.c:5067 [inline]
>      __x64_sys_bpf+0x75/0xb0 kernel/bpf/syscall.c:5067
>      do_syscall_x64 arch/x86/entry/common.c:50 [inline]
>      do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
>      entry_SYSCALL_64_after_hwframe+0x63/0xcd
> 
> [...]

Here is the summary with links:
  - [bpf-next,1/2] selftests/bpf: Add reproducer for decl_tag in func_proto return type
    https://git.kernel.org/bpf/bpf/c/35cc9d622e8c
  - [bpf-next,2/2] bpf: prevent decl_tag from being referenced in func_proto
    https://git.kernel.org/bpf/bpf/c/ea68376c8bed

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 127b8caa3dc1..24dd6214394e 100644
--- a/tools/testing/selftests/bpf/prog_tests/btf.c
+++ b/tools/testing/selftests/bpf/prog_tests/btf.c
@@ -3935,6 +3935,19 @@  static struct btf_raw_test raw_tests[] = {
 	.btf_load_err = true,
 	.err_str = "Invalid type_id",
 },
+{
+	.descr = "decl_tag test #16, func proto, return type",
+	.raw_types = {
+		BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4),				/* [1] */
+		BTF_VAR_ENC(NAME_TBD, 1, 0),						/* [2] */
+		BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_DECL_TAG, 0, 0), 2), (-1),	/* [3] */
+		BTF_FUNC_PROTO_ENC(3, 0),						/* [4] */
+		BTF_END_RAW,
+	},
+	BTF_STR_SEC("\0local\0tag1"),
+	.btf_load_err = true,
+	.err_str = "Invalid return type",
+},
 {
 	.descr = "type_tag test #1",
 	.raw_types = {