aboutsummaryrefslogtreecommitdiffstats
path: root/sys/fuchsia
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2020-06-03 11:44:46 -0700
committerMarco Vanotti <mvanotti@users.noreply.github.com>2020-06-05 15:08:57 -0300
commit57a83e9453bb2d0f4c80e00df72aa4317dcac58f (patch)
tree9824afd2d65c2431f57021f937d56c131f9f4e24 /sys/fuchsia
parentd36418e90bb0c3c89f2721f61b61b257758661f3 (diff)
sys/fuchsia: update "make extract" support code
FIDL fuzzing hasn't been working for a while, and it's further bit-rotted as upstream FIDL functionality has continued to evolve. This commit updates enough FIDL functionality to get a minimal FIDL test case to work again.
Diffstat (limited to 'sys/fuchsia')
-rw-r--r--sys/fuchsia/fidl.txt7
-rw-r--r--sys/fuchsia/fidlgen/main.go13
-rw-r--r--sys/fuchsia/layout/fidl_mappings.go59
-rw-r--r--sys/fuchsia/objects.txt3
-rw-r--r--sys/fuchsia/streams.txt8
5 files changed, 33 insertions, 57 deletions
diff --git a/sys/fuchsia/fidl.txt b/sys/fuchsia/fidl.txt
index 6c0f9a78f..8aace5d9c 100644
--- a/sys/fuchsia/fidl.txt
+++ b/sys/fuchsia/fidl.txt
@@ -1,7 +1,7 @@
# Copyright 2018 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.
-# See https://fuchsia.googlesource.com/fuchsia/+/master/docs/development/languages/fidl/reference/wire-format/README.md
+# See https://fuchsia.dev/fuchsia-src/reference/fidl/language/wire-format
include <zircon/fidl.h>
@@ -23,9 +23,8 @@ type fidl_union_member[TAG, TYPE] {
type fidl_message_header[METHOD_ORDINAL] {
txid const[0, int32]
- reserved const[0, int32]
- flags const[0, int32]
-# TODO: this should be int32, but the consts passed here don't fit into 32 bits.
+ flags array[const[0, int8], 3]
+ magic_number const[1, int8]
ordinal const[METHOD_ORDINAL, int64]
}
diff --git a/sys/fuchsia/fidlgen/main.go b/sys/fuchsia/fidlgen/main.go
index 139d6461d..63f1ca120 100644
--- a/sys/fuchsia/fidlgen/main.go
+++ b/sys/fuchsia/fidlgen/main.go
@@ -35,7 +35,7 @@ func main() {
"out",
arch,
"host_x64",
- "fidlgen",
+ "fidlgen_syzkaller",
)
if !osutil.IsExist(fidlgenPath) {
failf("cannot find fidlgen %s", fidlgenPath)
@@ -44,7 +44,7 @@ func main() {
var newFiles []string
for _, fidlLib := range layout.AllFidlLibraries {
jsonPath := filepath.Join(sourceDir, "out", arch, fidlLib.PathToJSONIr())
- txtPathBase := strings.Replace(strings.Join(fidlLib.FqName, "_"), "^fuchsia", "fidl", 1)
+ txtPathBase := strings.Replace(strings.Join(fidlLib, "_"), "^fuchsia", "fidl", 1)
txtPath := fidlgen(
fidlgenPath,
@@ -98,13 +98,14 @@ func fidlgen(fidlgenPath string, jsonPath string, txtPathBase string) string {
failf("cannot find %s", jsonPath)
}
- _, err := osutil.RunCmd(time.Minute, "",
+ out, err := osutil.RunCmd(time.Minute, "",
fidlgenPath,
- "-generators", "syzkaller",
"-json", jsonPath,
- "-output-base", txtPathBase,
- "-include-base", txtPathBase,
+ "-output-syz", txtPathBase+".syz.txt",
)
+ if len(out) != 0 {
+ fmt.Println(string(out))
+ }
if err != nil {
failf("fidlgen failed: %v", err)
diff --git a/sys/fuchsia/layout/fidl_mappings.go b/sys/fuchsia/layout/fidl_mappings.go
index 837a97332..44fb308e1 100644
--- a/sys/fuchsia/layout/fidl_mappings.go
+++ b/sys/fuchsia/layout/fidl_mappings.go
@@ -9,50 +9,24 @@ import (
"strings"
)
-// layer indicates at which layer a FidlLibrary lives in the Fuchsia build
-// system.
-type layer int
-
-const (
- _ layer = iota
- zircon
- garnet
-)
-
-// FidlLibrary describes a FIDL library. It captures required details such as
-// build location, header generation, etc.
-type FidlLibrary struct {
- layer layer
-
- // FqName stores the fully-qualified name of the library in parts, e.g.
- // the `fuchsia.mem` library is `fuchsia`, `mem`.
- FqName []string
-}
+// FidlLibrary is the fully-qualified name of a FIDL library.
+type FidlLibrary []string
// AllFidlLibraries lists all FIDL libraries.
var AllFidlLibraries = []FidlLibrary{
- {zircon, []string{"fuchsia", "mem"}},
- {zircon, []string{"fuchsia", "cobalt"}},
- {zircon, []string{"fuchsia", "ldsvc"}},
- {zircon, []string{"fuchsia", "process"}},
- {zircon, []string{"fuchsia", "io"}},
- {zircon, []string{"fuchsia", "net"}},
- {zircon, []string{"fuchsia", "hardware", "ethernet"}},
- {garnet, []string{"fuchsia", "devicesettings"}},
- {garnet, []string{"fuchsia", "net", "stack"}},
- {garnet, []string{"fuchsia", "timezone"}},
- {garnet, []string{"fuchsia", "scpi"}},
+ {"fuchsia", "cobalt"},
+ {"fuchsia", "devicesettings"},
+ {"fuchsia", "hardware", "ethernet"},
+ {"fuchsia", "io"},
+ {"fuchsia", "ldsvc"},
+ {"fuchsia", "mem"},
+ {"fuchsia", "net"},
+ {"fuchsia", "process"},
+ {"fuchsia", "scpi"},
}
func (fidlLib FidlLibrary) dirName() string {
- switch fidlLib.layer {
- case zircon:
- return strings.Join(fidlLib.FqName, "-")
- case garnet:
- return strings.Join(fidlLib.FqName, ".")
- default:
- panic(fmt.Sprintf("unknown layer %v", fidlLib.layer))
- }
+ return strings.Join(fidlLib, ".")
}
// PathToJSONIr provides the path to the JSON IR, relative to the out/<arch>
@@ -66,12 +40,5 @@ func (fidlLib FidlLibrary) PathToJSONIr() string {
// PathToCompiledDir provides the path to compiled headers, relative to the
// out/<arch> directory.
func (fidlLib FidlLibrary) PathToCompiledDir() string {
- switch fidlLib.layer {
- case zircon:
- return filepath.Join("fidling", "gen", "zircon", "system", "fidl", fidlLib.dirName())
- case garnet:
- return filepath.Join("fidling", "gen", "sdk", "fidl", fidlLib.dirName())
- default:
- panic(fmt.Sprintf("unknown layer %v", fidlLib.layer))
- }
+ return filepath.Join("fidling", "gen", "sdk", "fidl", fidlLib.dirName())
}
diff --git a/sys/fuchsia/objects.txt b/sys/fuchsia/objects.txt
index 4cc7c186a..922038525 100644
--- a/sys/fuchsia/objects.txt
+++ b/sys/fuchsia/objects.txt
@@ -2,8 +2,9 @@
# Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
include <zircon/syscalls.h>
-include <zircon/syscalls/object.h>
include <zircon/syscalls/exception.h>
+include <zircon/syscalls/object.h>
+include <zircon/syscalls/port.h>
resource koid[int64]: 0
diff --git a/sys/fuchsia/streams.txt b/sys/fuchsia/streams.txt
new file mode 100644
index 000000000..beb05e2d6
--- /dev/null
+++ b/sys/fuchsia/streams.txt
@@ -0,0 +1,8 @@
+# Copyright 2020 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.
+
+include <zircon/syscalls.h>
+
+resource zx_stream[zx_handle]
+
+# TODO: Add stream-related system calls.