Commit c0f264e4 authored by Jiri Olsa's avatar Jiri Olsa Committed by Alexei Starovoitov

bpf/selftests: Add verifier tests for loading sleepable programs

Adding verifier tests for loading all types od allowed
sleepable programs plus reject for tp_btf type.
Acked-by: default avatarSong Liu <song@kernel.org>
Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
Link: https://lore.kernel.org/r/20230117223705.440975-2-jolsa@kernel.orgSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent 700e6f85
{
"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 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 uprobe programs can be sleepable",
.flags = BPF_F_SLEEPABLE,
.runs = -1,
},
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment