diff mbox series

[bpf-next,2/2] selftests/bpf: Check combination of jit blinding and pointers to bpf subprogs.

Message ID 20220513011025.13344-2-alexei.starovoitov@gmail.com (mailing list archive)
State Accepted
Commit 365d519923a279af379a8d0f641ef50e44bb610e
Delegated to: BPF
Headers show
Series [bpf-next,1/2] bpf: Fix combination of jit blinding and pointers to bpf subprogs. | 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 9 maintainers not CCed: netdev@vger.kernel.org kafai@fb.com john.fastabend@gmail.com shuah@kernel.org yhs@fb.com kpsingh@kernel.org linux-kselftest@vger.kernel.org songliubraving@fb.com ast@kernel.org
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/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 20 lines checked
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-2 success Logs for Kernel LATEST on z15 + selftests
bpf/vmtest-bpf-next-PR success PR summary
bpf/vmtest-bpf-next-VM_Test-1 success Logs for Kernel LATEST on ubuntu-latest + selftests

Commit Message

Alexei Starovoitov May 13, 2022, 1:10 a.m. UTC
From: Alexei Starovoitov <ast@kernel.org>

Check that ld_imm64 with src_reg=1 (aka BPF_PSEUDO_FUNC) works
with jit_blinding.

Signed-off-by: Alexei Starovoitov <ast@kernel.org>
---
 tools/testing/selftests/bpf/progs/test_subprogs.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Andrii Nakryiko May 13, 2022, 3:45 a.m. UTC | #1
On Thu, May 12, 2022 at 6:10 PM Alexei Starovoitov
<alexei.starovoitov@gmail.com> wrote:
>
> From: Alexei Starovoitov <ast@kernel.org>
>
> Check that ld_imm64 with src_reg=1 (aka BPF_PSEUDO_FUNC) works
> with jit_blinding.
>
> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
> ---

Acked-by: Andrii Nakryiko <andrii@kernel.org>

>  tools/testing/selftests/bpf/progs/test_subprogs.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/tools/testing/selftests/bpf/progs/test_subprogs.c b/tools/testing/selftests/bpf/progs/test_subprogs.c
> index b7c37ca09544..f8e9256cf18d 100644
> --- a/tools/testing/selftests/bpf/progs/test_subprogs.c
> +++ b/tools/testing/selftests/bpf/progs/test_subprogs.c
> @@ -89,6 +89,11 @@ int prog2(void *ctx)
>         return 0;
>  }
>
> +static int empty_callback(__u32 index, void *data)
> +{
> +       return 0;
> +}
> +
>  /* prog3 has the same section name as prog1 */
>  SEC("raw_tp/sys_enter")
>  int prog3(void *ctx)
> @@ -98,6 +103,9 @@ int prog3(void *ctx)
>         if (!BPF_CORE_READ(t, pid) || !get_task_tgid((uintptr_t)t))
>                 return 1;
>
> +       /* test that ld_imm64 with BPF_PSEUDO_FUNC doesn't get blinded */
> +       bpf_loop(1, empty_callback, NULL, 0);
> +
>         res3 = sub3(5) + 6; /* (5 + 3 + (4 + 1)) + 6 = 19 */
>         return 0;
>  }
> --
> 2.30.2
>
Martin KaFai Lau May 13, 2022, 5:48 a.m. UTC | #2
On Thu, May 12, 2022 at 06:10:25PM -0700, Alexei Starovoitov wrote:
> From: Alexei Starovoitov <ast@kernel.org>
> 
> Check that ld_imm64 with src_reg=1 (aka BPF_PSEUDO_FUNC) works
> with jit_blinding.
Acked-by: Martin KaFai Lau <kafai@fb.com>
diff mbox series

Patch

diff --git a/tools/testing/selftests/bpf/progs/test_subprogs.c b/tools/testing/selftests/bpf/progs/test_subprogs.c
index b7c37ca09544..f8e9256cf18d 100644
--- a/tools/testing/selftests/bpf/progs/test_subprogs.c
+++ b/tools/testing/selftests/bpf/progs/test_subprogs.c
@@ -89,6 +89,11 @@  int prog2(void *ctx)
 	return 0;
 }
 
+static int empty_callback(__u32 index, void *data)
+{
+	return 0;
+}
+
 /* prog3 has the same section name as prog1 */
 SEC("raw_tp/sys_enter")
 int prog3(void *ctx)
@@ -98,6 +103,9 @@  int prog3(void *ctx)
 	if (!BPF_CORE_READ(t, pid) || !get_task_tgid((uintptr_t)t))
 		return 1;
 
+	/* test that ld_imm64 with BPF_PSEUDO_FUNC doesn't get blinded */
+	bpf_loop(1, empty_callback, NULL, 0);
+
 	res3 = sub3(5) + 6; /* (5 + 3 + (4 + 1)) + 6 = 19 */
 	return 0;
 }