diff options
| author | Anton Lindqvist <anton@basename.se> | 2020-07-21 09:03:53 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2020-07-21 12:15:13 +0200 |
| commit | 36f35f471467d3aa2fa9922902e2ed72d53f91a1 (patch) | |
| tree | 275da810b7f16ebdce6b22694148f1478eb5c482 /sys/openbsd | |
| parent | d88894e6773ab63ac8b3f4b2edbae88290aaf0d6 (diff) | |
sys/openbsd: neutralize sysctl kern.maxclusters
One of "no output from test machine" report causes[1]. Since it's a root
only knob, disallow fiddling with it for now.
[1] https://syzkaller.appspot.com/bug?id=a222a4193c0a9814e02fcc61b7343a5af04a7457
Diffstat (limited to 'sys/openbsd')
| -rw-r--r-- | sys/openbsd/init.go | 47 | ||||
| -rw-r--r-- | sys/openbsd/init_test.go | 5 |
2 files changed, 42 insertions, 10 deletions
diff --git a/sys/openbsd/init.go b/sys/openbsd/init.go index 3ed07b013..c40184724 100644 --- a/sys/openbsd/init.go +++ b/sys/openbsd/init.go @@ -13,11 +13,13 @@ import ( func InitTarget(target *prog.Target) { arch := &arch{ - unix: targets.MakeUnixNeutralizer(target), - DIOCKILLSTATES: target.GetConst("DIOCKILLSTATES"), - DIOCCLRSTATES: target.GetConst("DIOCCLRSTATES"), - S_IFMT: target.GetConst("S_IFMT"), - S_IFCHR: target.GetConst("S_IFCHR"), + unix: targets.MakeUnixNeutralizer(target), + CTL_KERN: target.GetConst("CTL_KERN"), + DIOCCLRSTATES: target.GetConst("DIOCCLRSTATES"), + DIOCKILLSTATES: target.GetConst("DIOCKILLSTATES"), + KERN_MAXCLUSTERS: target.GetConst("KERN_MAXCLUSTERS"), + S_IFCHR: target.GetConst("S_IFCHR"), + S_IFMT: target.GetConst("S_IFMT"), } target.MakeDataMmap = targets.MakePosixMmap(target, false, false) @@ -26,11 +28,13 @@ func InitTarget(target *prog.Target) { } type arch struct { - unix *targets.UnixNeutralizer - DIOCCLRSTATES uint64 - DIOCKILLSTATES uint64 - S_IFMT uint64 - S_IFCHR uint64 + unix *targets.UnixNeutralizer + CTL_KERN uint64 + DIOCCLRSTATES uint64 + DIOCKILLSTATES uint64 + KERN_MAXCLUSTERS uint64 + S_IFCHR uint64 + S_IFMT uint64 } const ( @@ -170,11 +174,34 @@ func (arch *arch) neutralize(c *prog.Call) { } } } + case "sysctl": + arch.neutralizeSysctl(c) default: arch.unix.Neutralize(c) } } +func (arch *arch) neutralizeSysctl(c *prog.Call) { + ptr := c.Args[0].(*prog.PointerArg) + if ptr.Res == nil { + return + } + + mib := ptr.Res.(*prog.GroupArg).Inner + if len(mib) < 2 { + return + } + + n1 := mib[0].(*prog.ConstArg) + n2 := mib[1].(*prog.ConstArg) + // Do not fiddle with root only knob kern.maxclusters, one of the causes + // of "no output from test machine" reports. + if n1.Val == arch.CTL_KERN && n2.Val == arch.KERN_MAXCLUSTERS { + n1.Val = 0 + n2.Val = 0 + } +} + func (arch *arch) annotateCall(c prog.ExecCall) string { devArg := 2 switch c.Meta.Name { diff --git a/sys/openbsd/init_test.go b/sys/openbsd/init_test.go index c4ec0c0bb..7635d2159 100644 --- a/sys/openbsd/init_test.go +++ b/sys/openbsd/init_test.go @@ -82,5 +82,10 @@ func TestNeutralize(t *testing.T) { // RLIMIT_CPU In: `setrlimit(0x0, &(0x7f0000cc0ff0)={0x1, 0x1})`, }, + { + // CTL_KERN, KERN_MAXCLUSTERS + In: `sysctl$kern(&(0x7f0000cc0ff0)={0x1, 0x43}, 0x0, 0x0, 0x0, &(0x7f0000000180), 0x0)`, + Out: `sysctl$kern(&(0x7f0000cc0ff0)={0x0}, 0x0, 0x0, 0x0, &(0x7f0000000180), 0x0)`, + }, }) } |
