sys/openbsd: sanitize mlockall syscalls

Locking down future mappings will most likely cause syz-executor to run
out of memory.

This is one of the root causes of the high amount of reported "lost
connection to test machine".
This commit is contained in:
Anton Lindqvist 2019-06-14 17:59:10 +02:00
parent 1dcdf7ef37
commit 442206d76b
2 changed files with 11 additions and 0 deletions

View File

@ -42,6 +42,9 @@ const (
// kOutPipeFd in executor/executor.cc
kcovFdMinorMax = 248
// MCL_FUTURE from openbsd:src/sys/sys/mman.h
mclFuture uint64 = 0x2
// RLIMIT_DATA from openbsd:src/sys/sys/resource.h
rlimitData = 2
// RLIMIT_STACK from openbsd:src/sys/sys/resource.h
@ -112,6 +115,9 @@ func (arch *arch) SanitizeCall(c *prog.Call) {
if devmajor(dev.Val) == 4 && devminor(dev.Val) == 2 {
dev.Val = devNullDevT
}
case "mlockall":
flags := c.Args[0].(*prog.ConstArg)
flags.Val &= ^mclFuture
case "setrlimit":
var rlimitMin uint64
var rlimitMax uint64 = math.MaxUint64

View File

@ -46,6 +46,11 @@ func TestSanitizeCall(t *testing.T) {
`mknod(0x0, 0x0, 0x0402)`,
`mknod(0x0, 0x0, 0x202)`,
},
{
// MCL_CURRENT | MCL_FUTURE
`mlockall(0x3)`,
`mlockall(0x1)`,
},
{
// RLIMIT_DATA
`setrlimit(0x2, &(0x7f0000cc0ff0)={0x0, 0x80000000})`,