Re: [PATCHv2 bpf-next 2/2] bpf/selftests: Add verifier tests for loading sleepable programs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jan 11, 2023 at 2:13 AM Jiri Olsa <jolsa@xxxxxxxxxx> wrote:
>
> Adding verifier tests for loading all types od allowed
> sleepable programs plus reject for tp_btf type.
>
> Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>

Acked-by: Song Liu <song@xxxxxxxxxx>

> ---
>  .../selftests/bpf/verifier/sleepable.c        | 91 +++++++++++++++++++
>  1 file changed, 91 insertions(+)
>  create mode 100644 tools/testing/selftests/bpf/verifier/sleepable.c
>
> diff --git a/tools/testing/selftests/bpf/verifier/sleepable.c b/tools/testing/selftests/bpf/verifier/sleepable.c
> new file mode 100644
> index 000000000000..15da44f7ac8a
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/verifier/sleepable.c
> @@ -0,0 +1,91 @@
> +{
> +       "sleepable fentry accept",
> +       .insns = {
> +       BPF_MOV64_IMM(BPF_REG_0, 0),
> +       BPF_EXIT_INSN(),
> +       },
> +       .prog_type = BPF_PROG_TYPE_TRACING,
> +       .expected_attach_type = BPF_TRACE_FENTRY,
> +       .kfunc = "bpf_fentry_test1",
> +       .result = ACCEPT,
> +       .flags = BPF_F_SLEEPABLE,
> +       .runs = -1,
> +},
> +{
> +       "sleepable fexit accept",
> +       .insns = {
> +       BPF_MOV64_IMM(BPF_REG_0, 0),
> +       BPF_EXIT_INSN(),
> +       },
> +       .prog_type = BPF_PROG_TYPE_TRACING,
> +       .expected_attach_type = BPF_TRACE_FENTRY,
> +       .kfunc = "bpf_fentry_test1",
> +       .result = ACCEPT,
> +       .flags = BPF_F_SLEEPABLE,
> +       .runs = -1,
> +},
> +{
> +       "sleepable fmod_ret accept",
> +       .insns = {
> +       BPF_MOV64_IMM(BPF_REG_0, 0),
> +       BPF_EXIT_INSN(),
> +       },
> +       .prog_type = BPF_PROG_TYPE_TRACING,
> +       .expected_attach_type = BPF_MODIFY_RETURN,
> +       .kfunc = "bpf_fentry_test1",
> +       .result = ACCEPT,
> +       .flags = BPF_F_SLEEPABLE,
> +       .runs = -1,
> +},
> +{
> +       "sleepable iter accept",
> +       .insns = {
> +       BPF_MOV64_IMM(BPF_REG_0, 0),
> +       BPF_EXIT_INSN(),
> +       },
> +       .prog_type = BPF_PROG_TYPE_TRACING,
> +       .expected_attach_type = BPF_TRACE_ITER,
> +       .kfunc = "task",
> +       .result = ACCEPT,
> +       .flags = BPF_F_SLEEPABLE,
> +       .runs = -1,
> +},
> +{
> +       "sleepable lsm accept",
> +       .insns = {
> +       BPF_MOV64_IMM(BPF_REG_0, 0),
> +       BPF_EXIT_INSN(),
> +       },
> +       .prog_type = BPF_PROG_TYPE_LSM,
> +       .kfunc = "bpf",
> +       .expected_attach_type = BPF_LSM_MAC,
> +       .result = ACCEPT,
> +       .flags = BPF_F_SLEEPABLE,
> +       .runs = -1,
> +},
> +{
> +       "sleepable kprobe/uprobe accept",
> +       .insns = {
> +       BPF_MOV64_IMM(BPF_REG_0, 0),
> +       BPF_EXIT_INSN(),
> +       },
> +       .prog_type = BPF_PROG_TYPE_KPROBE,
> +       .kfunc = "bpf_fentry_test1",
> +       .result = ACCEPT,
> +       .flags = BPF_F_SLEEPABLE,
> +       .runs = -1,
> +},
> +{
> +       "sleepable raw tracepoint reject",
> +       .insns = {
> +       BPF_MOV64_IMM(BPF_REG_0, 0),
> +       BPF_EXIT_INSN(),
> +       },
> +       .prog_type = BPF_PROG_TYPE_TRACING,
> +       .expected_attach_type = BPF_TRACE_RAW_TP,
> +       .kfunc = "sched_switch",
> +       .result = REJECT,
> +       .errstr = "Only fentry/fexit/fmod_ret, lsm, iter and kprobe/uprobe programs can be sleepable",
> +       .flags = BPF_F_SLEEPABLE,
> +       .runs = -1,
> +},
> --
> 2.39.0
>



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux