aboutsummaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorjuanPabloMiceli <48705702+juanPabloMiceli@users.noreply.github.com>2023-01-19 15:59:14 -0500
committerGitHub <noreply@github.com>2023-01-19 15:59:14 -0500
commit551737f1076a910f809cc27ac629c587bc84fc2d (patch)
tree7e847ee19f02e49269ac04437a5e62852aa2bf7e /pkg
parent71197f3ac138d7cb03551b7d2159bfc4ecf5c5c2 (diff)
vm/starnix: add support for fuzzing starnix (#3624)
This commit adds a new VM for fuzzing starnix. The VM will boot a fuchsia image using the `ffx` tool and will connect to an adb server inside it. Fuzzing will be done using HostFuzzer mode due to some features not being implemented yet in starnix. Once this is possible, fuzzing will be performed without HostFuzzer mode. Co-authored-by: Juampi Miceli <jpmiceli@google.com>
Diffstat (limited to 'pkg')
-rw-r--r--pkg/csource/generated.go14
-rw-r--r--pkg/osutil/osutil.go5
-rw-r--r--pkg/report/report.go3
3 files changed, 14 insertions, 8 deletions
diff --git a/pkg/csource/generated.go b/pkg/csource/generated.go
index 955d7c971..3921d1b6e 100644
--- a/pkg/csource/generated.go
+++ b/pkg/csource/generated.go
@@ -4378,7 +4378,7 @@ static long syz_memcpy_off(volatile long a0, volatile long a1, volatile long a2,
}
#endif
-#if SYZ_EXECUTOR || SYZ_REPEAT && SYZ_NET_INJECTION
+#if (SYZ_EXECUTOR || SYZ_REPEAT && SYZ_NET_INJECTION) && SYZ_EXECUTOR_USES_FORK_SERVER
static void flush_tun()
{
#if SYZ_EXECUTOR
@@ -8173,7 +8173,7 @@ static volatile long syz_kvm_setup_cpu(volatile long a0, volatile long a1, volat
#endif
#endif
-#if SYZ_EXECUTOR || SYZ_NET_RESET
+#if (SYZ_EXECUTOR || SYZ_NET_RESET) && SYZ_EXECUTOR_USES_FORK_SERVER
#include <errno.h>
#include <net/if.h>
#include <netinet/in.h>
@@ -8719,7 +8719,7 @@ static void setup_cgroups()
write_file("/syzcgroup/cpu/cpuset.memory_pressure_enabled", "1");
}
-#if SYZ_EXECUTOR || SYZ_REPEAT
+#if (SYZ_EXECUTOR || SYZ_REPEAT) && SYZ_EXECUTOR_USES_FORK_SERVER
static void setup_cgroups_loop()
{
#if SYZ_EXECUTOR
@@ -10542,7 +10542,7 @@ static int fault_injected(int fail_fd)
}
#endif
-#if SYZ_EXECUTOR || SYZ_REPEAT
+#if (SYZ_EXECUTOR || SYZ_REPEAT) && SYZ_EXECUTOR_USES_FORK_SERVER
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
@@ -10592,7 +10592,7 @@ static void kill_and_wait(int pid, int* status)
}
#endif
-#if SYZ_EXECUTOR || SYZ_REPEAT && (SYZ_CGROUPS || SYZ_NET_RESET)
+#if (SYZ_EXECUTOR || SYZ_REPEAT && (SYZ_CGROUPS || SYZ_NET_RESET)) && SYZ_EXECUTOR_USES_FORK_SERVER
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
@@ -10611,7 +10611,7 @@ static void setup_loop()
}
#endif
-#if SYZ_EXECUTOR || SYZ_REPEAT && (SYZ_NET_RESET || __NR_syz_mount_image || __NR_syz_read_part_table)
+#if (SYZ_EXECUTOR || SYZ_REPEAT && (SYZ_NET_RESET || __NR_syz_mount_image || __NR_syz_read_part_table)) && SYZ_EXECUTOR_USES_FORK_SERVER
#define SYZ_HAVE_RESET_LOOP 1
static void reset_loop()
{
@@ -10630,7 +10630,7 @@ static void reset_loop()
}
#endif
-#if SYZ_EXECUTOR || SYZ_REPEAT
+#if (SYZ_EXECUTOR || SYZ_REPEAT) && SYZ_EXECUTOR_USES_FORK_SERVER
#include <sys/prctl.h>
#include <unistd.h>
diff --git a/pkg/osutil/osutil.go b/pkg/osutil/osutil.go
index c07c6372b..6ac96b344 100644
--- a/pkg/osutil/osutil.go
+++ b/pkg/osutil/osutil.go
@@ -130,6 +130,11 @@ func PrependContext(ctx string, err error) error {
}
}
+func IsDir(name string) bool {
+ fileInfo, err := os.Stat(name)
+ return err == nil && fileInfo.IsDir()
+}
+
// IsExist returns true if the file name exists.
func IsExist(name string) bool {
_, err := os.Stat(name)
diff --git a/pkg/report/report.go b/pkg/report/report.go
index 8a710e062..7dd9714b3 100644
--- a/pkg/report/report.go
+++ b/pkg/report/report.go
@@ -101,7 +101,7 @@ func (t Type) String() string {
// NewReporter creates reporter for the specified OS/Type.
func NewReporter(cfg *mgrconfig.Config) (*Reporter, error) {
typ := cfg.TargetOS
- if cfg.Type == "gvisor" {
+ if cfg.Type == "gvisor" || cfg.Type == "starnix" {
typ = cfg.Type
}
ctor := ctors[typ]
@@ -151,6 +151,7 @@ const (
var ctors = map[string]fn{
targets.Akaros: ctorAkaros,
targets.Linux: ctorLinux,
+ "starnix": ctorFuchsia,
"gvisor": ctorGvisor,
targets.FreeBSD: ctorFreebsd,
targets.Darwin: ctorDarwin,