diff --git a/CHANGELOG.md b/CHANGELOG.md index 7006d90..0cd72ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,11 @@ - New command `pack` that perform tests in subdirectories. +- Added ability to disable kaslr/smep/smap for in artifact definition. + +- Added ability to change amount of memory/CPUs and set qemu timeout + in artifact definition (`.out-of-tree.toml`). + ### Changed - Now if there's no base image found — out-of-tree will try to use diff --git a/config/config.go b/config/config.go index c20f7e5..2411b89 100644 --- a/config/config.go +++ b/config/config.go @@ -12,6 +12,7 @@ import ( "regexp" "strconv" "strings" + "time" "github.com/naoina/toml" ) @@ -83,12 +84,36 @@ func (at ArtifactType) MarshalTOML() (data []byte, err error) { return } +// Duration type with toml unmarshalling support +type Duration struct { + time.Duration +} + +// UnmarshalTOML for Duration +func (d *Duration) UnmarshalTOML(data []byte) (err error) { + duration := strings.Replace(string(data), "\"", "", -1) + d.Duration, err = time.ParseDuration(duration) + return +} + // Artifact is for .out-of-tree.toml type Artifact struct { Name string Type ArtifactType SourcePath string SupportedKernels []KernelMask + + Qemu struct { + CPUs int + Memory int + Timeout Duration + } + + Mitigations struct { + DisableSMEP bool + DisableSMAP bool + DisableKASLR bool + } } func (ka Artifact) checkSupport(ki KernelInfo, km KernelMask) ( diff --git a/pew.go b/pew.go index 0a35f43..dc76a37 100644 --- a/pew.go +++ b/pew.go @@ -304,6 +304,20 @@ func whatever(swg *sizedwaitgroup.SizedWaitGroup, ka config.Artifact, } q.Timeout = qemuTimeout + if ka.Qemu.Timeout.Duration != 0 { + q.Timeout = ka.Qemu.Timeout.Duration + } + if ka.Qemu.CPUs != 0 { + q.Cpus = ka.Qemu.CPUs + } + if ka.Qemu.Memory != 0 { + q.Memory = ka.Qemu.Memory + } + + q.SetKASLR(!ka.Mitigations.DisableKASLR) + q.SetSMEP(!ka.Mitigations.DisableSMEP) + q.SetSMAP(!ka.Mitigations.DisableSMAP) + err = q.Start() if err != nil { log.Println("Qemu start error:", err)