summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/bpf/verifier/basic_call.c
blob: a8c6ab4c1622f3eda8b22134cafbb79ee1e06fbb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
{
	"invalid call insn1",
	.insns = {
	BPF_RAW_INSN(BPF_JMP | BPF_CALL | BPF_X, 0, 0, 0, 0),
	BPF_EXIT_INSN(),
	},
	.errstr = "unknown opcode 8d",
	.result = REJECT,
},
{
	"invalid call insn2",
	.insns = {
	BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 1, 0),
	BPF_EXIT_INSN(),
	},
	.errstr = "BPF_CALL uses reserved",
	.result = REJECT,
},
{
	"invalid function call",
	.insns = {
	BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, 1234567),
	BPF_EXIT_INSN(),
	},
	.errstr = "invalid func unknown#1234567",
	.result = REJECT,
},
{
	"invalid argument register",
	.insns = {
	BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_get_cgroup_classid),
	BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_get_cgroup_classid),
	BPF_EXIT_INSN(),
	},
	.errstr = "R1 !read_ok",
	.result = REJECT,
	.prog_type = BPF_PROG_TYPE_SCHED_CLS,
},
{
	"non-invalid argument register",
	.insns = {
	BPF_ALU64_REG(BPF_MOV, BPF_REG_6, BPF_REG_1),
	BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_get_cgroup_classid),
	BPF_ALU64_REG(BPF_MOV, BPF_REG_1, BPF_REG_6),
	BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_get_cgroup_classid),
	BPF_EXIT_INSN(),
	},
	.result = ACCEPT,
	.prog_type = BPF_PROG_TYPE_SCHED_CLS,
},