summaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/bpf/verifier/const_or.c
blob: 0719b0ddec0405c0c444023659b325f5e1a83a98 (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
51
52
53
54
55
56
57
58
59
60
{
	"constant register |= constant should keep constant type",
	.insns = {
	BPF_MOV64_REG(BPF_REG_1, BPF_REG_10),
	BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, -48),
	BPF_MOV64_IMM(BPF_REG_2, 34),
	BPF_ALU64_IMM(BPF_OR, BPF_REG_2, 13),
	BPF_MOV64_IMM(BPF_REG_3, 0),
	BPF_EMIT_CALL(BPF_FUNC_probe_read_kernel),
	BPF_EXIT_INSN(),
	},
	.result = ACCEPT,
	.prog_type = BPF_PROG_TYPE_TRACEPOINT,
},
{
	"constant register |= constant should not bypass stack boundary checks",
	.insns = {
	BPF_MOV64_REG(BPF_REG_1, BPF_REG_10),
	BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, -48),
	BPF_MOV64_IMM(BPF_REG_2, 34),
	BPF_ALU64_IMM(BPF_OR, BPF_REG_2, 24),
	BPF_MOV64_IMM(BPF_REG_3, 0),
	BPF_EMIT_CALL(BPF_FUNC_probe_read_kernel),
	BPF_EXIT_INSN(),
	},
	.errstr = "invalid indirect access to stack R1 off=-48 size=58",
	.result = REJECT,
	.prog_type = BPF_PROG_TYPE_TRACEPOINT,
},
{
	"constant register |= constant register should keep constant type",
	.insns = {
	BPF_MOV64_REG(BPF_REG_1, BPF_REG_10),
	BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, -48),
	BPF_MOV64_IMM(BPF_REG_2, 34),
	BPF_MOV64_IMM(BPF_REG_4, 13),
	BPF_ALU64_REG(BPF_OR, BPF_REG_2, BPF_REG_4),
	BPF_MOV64_IMM(BPF_REG_3, 0),
	BPF_EMIT_CALL(BPF_FUNC_probe_read_kernel),
	BPF_EXIT_INSN(),
	},
	.result = ACCEPT,
	.prog_type = BPF_PROG_TYPE_TRACEPOINT,
},
{
	"constant register |= constant register should not bypass stack boundary checks",
	.insns = {
	BPF_MOV64_REG(BPF_REG_1, BPF_REG_10),
	BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, -48),
	BPF_MOV64_IMM(BPF_REG_2, 34),
	BPF_MOV64_IMM(BPF_REG_4, 24),
	BPF_ALU64_REG(BPF_OR, BPF_REG_2, BPF_REG_4),
	BPF_MOV64_IMM(BPF_REG_3, 0),
	BPF_EMIT_CALL(BPF_FUNC_probe_read_kernel),
	BPF_EXIT_INSN(),
	},
	.errstr = "invalid indirect access to stack R1 off=-48 size=58",
	.result = REJECT,
	.prog_type = BPF_PROG_TYPE_TRACEPOINT,
},