aboutsummaryrefslogtreecommitdiffstats
path: root/sys/openbsd/init_test.go
blob: 2a9ed640c5754e232f3a588e55dd89548811bf6a (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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// Copyright 2019 syzkaller project authors. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.

package openbsd_test

import (
	"testing"

	"github.com/google/syzkaller/prog"
	_ "github.com/google/syzkaller/sys/openbsd/gen"
	"github.com/google/syzkaller/sys/targets"
)

func TestNeutralize(t *testing.T) {
	prog.TestDeserializeHelper(t, targets.OpenBSD, targets.AMD64, nil, []prog.DeserializeTest{
		{
			In:  `chflagsat(0x0, 0x0, 0x60004, 0x0)`,
			Out: `chflagsat(0x0, 0x0, 0x0, 0x0)`,
		},
		{
			In:  `fchflags(0x0, 0x60004)`,
			Out: `fchflags(0x0, 0x0)`,
		},
		// Note, a random ioctl description used since only the command
		// is of importance.
		{
			In:  `ioctl$BIOCSDIRFILT(0x0, 0xc0e04429, 0x0)`,
			Out: `ioctl$BIOCSDIRFILT(0x0, 0x0, 0x0)`,
		},
		{
			In:  `ioctl$BIOCSDIRFILT(0x0, 0xc0e04412, 0x0)`,
			Out: `ioctl$BIOCSDIRFILT(0x0, 0x0, 0x0)`,
		},
		{
			// major=22, minor=232
			In:  `mknodat(0x0, 0x0, 0x0, 0x16e8)`,
			Out: `mknodat(0x0, 0x0, 0x0, 0x202)`,
		},
		{
			// major=22, minor=232
			In:  `mknod(0x0, 0x0, 0x16e8)`,
			Out: `mknod(0x0, 0x0, 0x202)`,
		},
		{
			// major=22, minor=0
			In: `mknod(0x0, 0x0, 0x1600)`,
		},
		{
			// major=4, minor=0
			In: `mknod(0x0, 0x0, 0x400)`,
		},
		{
			// major=4, minor=1
			In:  `mknod(0x0, 0x0, 0x401)`,
			Out: `mknod(0x0, 0x0, 0x202)`,
		},
		{
			// major=4, minor=2
			In:  `mknod(0x0, 0x0, 0x402)`,
			Out: `mknod(0x0, 0x0, 0x202)`,
		},
		{
			// MCL_CURRENT | MCL_FUTURE
			In:  `mlockall(0x3)`,
			Out: `mlockall(0x1)`,
		},
		{
			// RLIMIT_DATA
			In:  `setrlimit(0x2, &(0x7f0000cc0ff0)={0x0, 0x80000000})`,
			Out: `setrlimit(0x2, &(0x7f0000cc0ff0)={0x60000000, 0x80000000})`,
		},
		{
			// RLIMIT_DATA
			In:  `setrlimit(0x10000000000002, &(0x7f0000cc0ff0)={0x0, 0x80000000})`,
			Out: `setrlimit(0x10000000000002, &(0x7f0000cc0ff0)={0x60000000, 0x80000000})`,
		},
		{
			// RLIMIT_STACK
			In:  `setrlimit(0x3, &(0x7f0000cc0ff0)={0x1000000000, 0x1000000000})`,
			Out: `setrlimit(0x3, &(0x7f0000cc0ff0)={0x100000, 0x100000})`,
		},
		{
			// RLIMIT_CPU
			In: `setrlimit(0x0, &(0x7f0000cc0ff0)={0x1, 0x1})`,
		},
		{
			// Test for sysctl kern.maxclusters.
			In:  `sysctl$kern(&(0x7f0000cc0ff0)={0x1, 0x43}, 0x2, 0x0, 0x0, &(0x7f0000000180), 0x0)`,
			Out: `sysctl$kern(&(0x7f0000cc0ff0)={0x0}, 0x0, 0x0, 0x0, &(0x7f0000000180), 0x0)`,
		},
		{
			// Test for sysctl kern.maxthread.
			In:  `sysctl$kern(&(0x7f0000000300)={0x1, 0x19}, 0x2, 0x0, 0x0, &(0x7f0000000300)="ff0380c5", 0x4)`,
			Out: `sysctl$kern(&(0x7f0000000300)={0x0}, 0x0, 0x0, 0x0, &(0x7f0000000300)="ff0380c5", 0x4)`,
		},
		{
			// Test for sysctl kern.witness.
			In:  `sysctl$kern(&(0x7f0000000300)={0x1, 0x3c}, 0x2, 0x0, 0x0, &(0x7f0000000300)="ff0380c5", 0x4)`,
			Out: `sysctl$kern(&(0x7f0000000300)={0x0}, 0x0, 0x0, 0x0, &(0x7f0000000300)="ff0380c5", 0x4)`,
		},
		{
			In:  `clock_settime(0x0, &(0x7f0000cc0ff0)={0x0, 0x0})`,
			Out: `clock_settime(0xffffffffffffffff, &(0x7f0000cc0ff0))`,
		},
	})
}