xref: /openbmc/linux/tools/testing/selftests/bpf/verifier/sleepable.c (revision 9a87ffc99ec8eb8d35eed7c4f816d75f5cc9662e)
1c0f264e4SJiri Olsa {
2c0f264e4SJiri Olsa 	"sleepable fentry accept",
3c0f264e4SJiri Olsa 	.insns = {
4c0f264e4SJiri Olsa 	BPF_MOV64_IMM(BPF_REG_0, 0),
5c0f264e4SJiri Olsa 	BPF_EXIT_INSN(),
6c0f264e4SJiri Olsa 	},
7c0f264e4SJiri Olsa 	.prog_type = BPF_PROG_TYPE_TRACING,
8c0f264e4SJiri Olsa 	.expected_attach_type = BPF_TRACE_FENTRY,
9c0f264e4SJiri Olsa 	.kfunc = "bpf_fentry_test1",
10c0f264e4SJiri Olsa 	.result = ACCEPT,
11c0f264e4SJiri Olsa 	.flags = BPF_F_SLEEPABLE,
12c0f264e4SJiri Olsa 	.runs = -1,
13c0f264e4SJiri Olsa },
14c0f264e4SJiri Olsa {
15c0f264e4SJiri Olsa 	"sleepable fexit accept",
16c0f264e4SJiri Olsa 	.insns = {
17c0f264e4SJiri Olsa 	BPF_MOV64_IMM(BPF_REG_0, 0),
18c0f264e4SJiri Olsa 	BPF_EXIT_INSN(),
19c0f264e4SJiri Olsa 	},
20c0f264e4SJiri Olsa 	.prog_type = BPF_PROG_TYPE_TRACING,
21c0f264e4SJiri Olsa 	.expected_attach_type = BPF_TRACE_FENTRY,
22c0f264e4SJiri Olsa 	.kfunc = "bpf_fentry_test1",
23c0f264e4SJiri Olsa 	.result = ACCEPT,
24c0f264e4SJiri Olsa 	.flags = BPF_F_SLEEPABLE,
25c0f264e4SJiri Olsa 	.runs = -1,
26c0f264e4SJiri Olsa },
27c0f264e4SJiri Olsa {
28c0f264e4SJiri Olsa 	"sleepable fmod_ret accept",
29c0f264e4SJiri Olsa 	.insns = {
30c0f264e4SJiri Olsa 	BPF_MOV64_IMM(BPF_REG_0, 0),
31c0f264e4SJiri Olsa 	BPF_EXIT_INSN(),
32c0f264e4SJiri Olsa 	},
33c0f264e4SJiri Olsa 	.prog_type = BPF_PROG_TYPE_TRACING,
34c0f264e4SJiri Olsa 	.expected_attach_type = BPF_MODIFY_RETURN,
35c0f264e4SJiri Olsa 	.kfunc = "bpf_fentry_test1",
36c0f264e4SJiri Olsa 	.result = ACCEPT,
37c0f264e4SJiri Olsa 	.flags = BPF_F_SLEEPABLE,
38c0f264e4SJiri Olsa 	.runs = -1,
39c0f264e4SJiri Olsa },
40c0f264e4SJiri Olsa {
41c0f264e4SJiri Olsa 	"sleepable iter accept",
42c0f264e4SJiri Olsa 	.insns = {
43c0f264e4SJiri Olsa 	BPF_MOV64_IMM(BPF_REG_0, 0),
44c0f264e4SJiri Olsa 	BPF_EXIT_INSN(),
45c0f264e4SJiri Olsa 	},
46c0f264e4SJiri Olsa 	.prog_type = BPF_PROG_TYPE_TRACING,
47c0f264e4SJiri Olsa 	.expected_attach_type = BPF_TRACE_ITER,
48c0f264e4SJiri Olsa 	.kfunc = "task",
49c0f264e4SJiri Olsa 	.result = ACCEPT,
50c0f264e4SJiri Olsa 	.flags = BPF_F_SLEEPABLE,
51c0f264e4SJiri Olsa 	.runs = -1,
52c0f264e4SJiri Olsa },
53c0f264e4SJiri Olsa {
54c0f264e4SJiri Olsa 	"sleepable lsm accept",
55c0f264e4SJiri Olsa 	.insns = {
56c0f264e4SJiri Olsa 	BPF_MOV64_IMM(BPF_REG_0, 0),
57c0f264e4SJiri Olsa 	BPF_EXIT_INSN(),
58c0f264e4SJiri Olsa 	},
59c0f264e4SJiri Olsa 	.prog_type = BPF_PROG_TYPE_LSM,
60c0f264e4SJiri Olsa 	.kfunc = "bpf",
61c0f264e4SJiri Olsa 	.expected_attach_type = BPF_LSM_MAC,
62c0f264e4SJiri Olsa 	.result = ACCEPT,
63c0f264e4SJiri Olsa 	.flags = BPF_F_SLEEPABLE,
64c0f264e4SJiri Olsa 	.runs = -1,
65c0f264e4SJiri Olsa },
66c0f264e4SJiri Olsa {
67c0f264e4SJiri Olsa 	"sleepable uprobe accept",
68c0f264e4SJiri Olsa 	.insns = {
69c0f264e4SJiri Olsa 	BPF_MOV64_IMM(BPF_REG_0, 0),
70c0f264e4SJiri Olsa 	BPF_EXIT_INSN(),
71c0f264e4SJiri Olsa 	},
72c0f264e4SJiri Olsa 	.prog_type = BPF_PROG_TYPE_KPROBE,
73c0f264e4SJiri Olsa 	.kfunc = "bpf_fentry_test1",
74c0f264e4SJiri Olsa 	.result = ACCEPT,
75c0f264e4SJiri Olsa 	.flags = BPF_F_SLEEPABLE,
76c0f264e4SJiri Olsa 	.runs = -1,
77c0f264e4SJiri Olsa },
78c0f264e4SJiri Olsa {
79c0f264e4SJiri Olsa 	"sleepable raw tracepoint reject",
80c0f264e4SJiri Olsa 	.insns = {
81c0f264e4SJiri Olsa 	BPF_MOV64_IMM(BPF_REG_0, 0),
82c0f264e4SJiri Olsa 	BPF_EXIT_INSN(),
83c0f264e4SJiri Olsa 	},
84c0f264e4SJiri Olsa 	.prog_type = BPF_PROG_TYPE_TRACING,
85c0f264e4SJiri Olsa 	.expected_attach_type = BPF_TRACE_RAW_TP,
86c0f264e4SJiri Olsa 	.kfunc = "sched_switch",
87c0f264e4SJiri Olsa 	.result = REJECT,
88*1e12d3efSDavid Vernet 	.errstr = "Only fentry/fexit/fmod_ret, lsm, iter, uprobe, and struct_ops programs can be sleepable",
89c0f264e4SJiri Olsa 	.flags = BPF_F_SLEEPABLE,
90c0f264e4SJiri Olsa 	.runs = -1,
91c0f264e4SJiri Olsa },
92