mirror of
https://github.com/reactos/syzkaller.git
synced 2025-02-26 14:45:32 +00:00

Currently when we get target consts with target.ConstMap["name"] during target initialization, we just get 0 for missing consts. This is error-prone as we can mis-type a const, or a const may be undefined only on some archs (as we have common unix code shared between several OSes). Check that all the consts are actually defined. The check detects several violations, to fix them: 1. move mremap to linux as it's only defined on linux 2. move S_IFMT to openbsd, as it's only defined and used on openbsd 3. define missing MAP_ANONYMOUS for freebsd and netbsd 4. fix extract for netbsd
42 lines
1.1 KiB
Go
42 lines
1.1 KiB
Go
// Copyright 2017 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 windows
|
|
|
|
import (
|
|
"github.com/google/syzkaller/prog"
|
|
)
|
|
|
|
func InitTarget(target *prog.Target) {
|
|
arch := &arch{
|
|
virtualAllocSyscall: target.SyscallMap["VirtualAlloc"],
|
|
MEM_COMMIT: target.GetConst("MEM_COMMIT"),
|
|
MEM_RESERVE: target.GetConst("MEM_RESERVE"),
|
|
PAGE_EXECUTE_READWRITE: target.GetConst("PAGE_EXECUTE_READWRITE"),
|
|
}
|
|
|
|
target.MakeMmap = arch.makeMmap
|
|
}
|
|
|
|
type arch struct {
|
|
virtualAllocSyscall *prog.Syscall
|
|
|
|
MEM_COMMIT uint64
|
|
MEM_RESERVE uint64
|
|
PAGE_EXECUTE_READWRITE uint64
|
|
}
|
|
|
|
func (arch *arch) makeMmap(addr, size uint64) *prog.Call {
|
|
meta := arch.virtualAllocSyscall
|
|
return &prog.Call{
|
|
Meta: meta,
|
|
Args: []prog.Arg{
|
|
prog.MakeVmaPointerArg(meta.Args[0], addr, size),
|
|
prog.MakeConstArg(meta.Args[1], size),
|
|
prog.MakeConstArg(meta.Args[2], arch.MEM_COMMIT|arch.MEM_RESERVE),
|
|
prog.MakeConstArg(meta.Args[3], arch.PAGE_EXECUTE_READWRITE),
|
|
},
|
|
Ret: prog.MakeReturnArg(meta.Ret),
|
|
}
|
|
}
|