diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2018-08-30 13:02:07 -0700 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2018-08-30 21:44:56 -0700 |
| commit | 6ba5fe3e62880ddf8aeec68ab44eabaa8bc148b8 (patch) | |
| tree | 8320d857b2e61a423f7d0b349e3dfe9274943397 | |
| parent | ee42876f958cee5e90c650618fe994307a260397 (diff) | |
sys/openbsd: disable mknod sanitization as tests fail
TestSerializeDeserializeRandom fails from time to time
because program is different after we serialize/deserialize it.
Turns out openbsd SanitizeCall is not idempotent.
Add a test for this and disable the logic for now.
| -rw-r--r-- | prog/prog_test.go | 16 | ||||
| -rw-r--r-- | sys/openbsd/init.go | 39 |
2 files changed, 37 insertions, 18 deletions
diff --git a/prog/prog_test.go b/prog/prog_test.go index 967b93210..29b4d385e 100644 --- a/prog/prog_test.go +++ b/prog/prog_test.go @@ -397,3 +397,19 @@ fallback$0() }) } } + +func TestSanitizeRandom(t *testing.T) { + testEachTargetRandom(t, func(t *testing.T, target *Target, rs rand.Source, iters int) { + for i := 0; i < iters; i++ { + p := target.Generate(rs, 10, nil) + s0 := string(p.Serialize()) + for _, c := range p.Calls { + target.SanitizeCall(c) + } + s1 := string(p.Serialize()) + if s0 != s1 { + t.Fatalf("non-sanitized program or non-idempotent sanitize\nwas: %v\ngot: %v", s0, s1) + } + } + }) +} diff --git a/sys/openbsd/init.go b/sys/openbsd/init.go index ac06ad644..3f4641405 100644 --- a/sys/openbsd/init.go +++ b/sys/openbsd/init.go @@ -26,24 +26,27 @@ func (arch *arch) SanitizeCall(c *prog.Call) { // Prevent vnodes of type VBAD from being created. Such vnodes will // likely trigger assertion errors by the kernel. - pos := 1 - switch c.Meta.CallName { - case "mknodat": - pos = 2 - fallthrough - case "mknod": - mode := c.Args[pos].(*prog.ConstArg) - if (mode.Val & arch.unix.S_IFMT) != arch.unix.S_IFMT { - return - } - saneMode := mode.Val & ^arch.unix.S_IFMT - switch { - case (mode.Val & arch.unix.S_IFCHR) == arch.unix.S_IFCHR: - mode.Val = saneMode | arch.unix.S_IFCHR - case (mode.Val & arch.unix.S_IFBLK) == arch.unix.S_IFBLK: - mode.Val = saneMode | arch.unix.S_IFBLK - case (mode.Val & arch.unix.S_IFIFO) == arch.unix.S_IFIFO: - mode.Val = saneMode | arch.unix.S_IFIFO + // TODO(dvyukov): this is disabled for now because TestSanitizeRandom fails. + if false { + pos := 1 + switch c.Meta.CallName { + case "mknodat": + pos = 2 + fallthrough + case "mknod": + mode := c.Args[pos].(*prog.ConstArg) + if mode.Val&arch.unix.S_IFMT != arch.unix.S_IFMT { + return + } + saneMode := mode.Val & ^arch.unix.S_IFMT + switch { + case mode.Val&arch.unix.S_IFCHR == arch.unix.S_IFCHR: + mode.Val = saneMode | arch.unix.S_IFCHR + case mode.Val&arch.unix.S_IFBLK == arch.unix.S_IFBLK: + mode.Val = saneMode | arch.unix.S_IFBLK + case mode.Val&arch.unix.S_IFIFO == arch.unix.S_IFIFO: + mode.Val = saneMode | arch.unix.S_IFIFO + } } } } |
