diff options
| author | Anton Lindqvist <anton@basename.se> | 2019-01-19 18:30:04 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2019-01-19 19:22:37 +0100 |
| commit | 141c212ca6fdc95f4017af0c856768337242bb2e (patch) | |
| tree | 5923884937ed4e45582069f1f73b572184835a68 /sys/openbsd/init_test.go | |
| parent | e935237c9c7214eb37cb35a93c9930b590016094 (diff) | |
sys/openbsd: avoid /dev/fd node creation
Prevent nodes that maps to an already open kcov fd from being created since
they can corrupt the coverage buffer.
Partial revert of commit 04aed72692137822b809098c55401dd3493dd0f6 with some
tweaks and testing.
Diffstat (limited to 'sys/openbsd/init_test.go')
| -rw-r--r-- | sys/openbsd/init_test.go | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/sys/openbsd/init_test.go b/sys/openbsd/init_test.go new file mode 100644 index 000000000..780fe3efb --- /dev/null +++ b/sys/openbsd/init_test.go @@ -0,0 +1,50 @@ +package openbsd_test + +import ( + "fmt" + "strings" + "testing" + + "github.com/google/syzkaller/prog" + _ "github.com/google/syzkaller/sys/openbsd/gen" +) + +func TestSanitizeMknodCall(t *testing.T) { + target, err := prog.GetTarget("openbsd", "amd64") + if err != nil { + t.Fatal(err) + } + tests := []struct { + input string + output string + }{ + { + // major=22, minor=232 + `mknodat(0x0, 0x0, 0x0, 0x16e8)`, + `mknodat(0x0, 0x0, 0x0, 0x202)`, + }, + { + // major=22, minor=232 + `mknod(0x0, 0x0, 0x16e8)`, + `mknod(0x0, 0x0, 0x202)`, + }, + { + // major=22, minor=0 + `mknod(0x0, 0x0, 0x1600)`, + `mknod(0x0, 0x0, 0x1600)`, + }, + } + for i, test := range tests { + t.Run(fmt.Sprint(i), func(t *testing.T) { + p, err := target.Deserialize([]byte(test.input), prog.Strict) + if err != nil { + t.Fatal(err) + } + got := strings.TrimSpace(string(p.Serialize())) + want := strings.TrimSpace(test.output) + if got != want { + t.Fatalf("input:\n%v\ngot:\n%v\nwant:\n%s", test.input, got, want) + } + }) + } +} |
