mirror of
https://github.com/reactos/syzkaller.git
synced 2025-02-14 16:38:40 +00:00
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.
This commit is contained in:
parent
d36418e90b
commit
57a83e9453
@ -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]
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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())
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
8
sys/fuchsia/streams.txt
Normal file
8
sys/fuchsia/streams.txt
Normal file
@ -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.
|
@ -25,18 +25,22 @@ func (*fuchsia) prepareArch(arch *Arch) error {
|
||||
}
|
||||
|
||||
func (*fuchsia) processFile(arch *Arch, info *compiler.ConstInfo) (map[string]uint64, map[string]bool, error) {
|
||||
dir := arch.sourceDir
|
||||
headerArch := arch.target.KernelHeaderArch
|
||||
cc := filepath.Join(dir, "prebuilt", "third_party", "clang", "linux-x64", "bin", "clang")
|
||||
includeDir := filepath.Join(dir, "out", headerArch, "sdk", "exported",
|
||||
"zircon_sysroot", "arch", headerArch, "sysroot", "include")
|
||||
args := []string{"-fmessage-length=0", "-I" + includeDir}
|
||||
srcDir := arch.sourceDir
|
||||
outDir := filepath.Join(srcDir, "out", arch.target.KernelHeaderArch)
|
||||
|
||||
cc := filepath.Join(srcDir, "prebuilt/third_party/clang/linux-x64/bin/clang")
|
||||
args := []string{
|
||||
"-fmessage-length=0",
|
||||
"-I", filepath.Join(outDir, "zircon_toolchain/obj/zircon/public/sysroot/sysroot/include"),
|
||||
"-I", filepath.Join(outDir, "fidling/gen/zircon/vdso/zx"),
|
||||
}
|
||||
for _, fidlLib := range layout.AllFidlLibraries {
|
||||
args = append(args, "-I"+filepath.Join(dir, "out", headerArch, fidlLib.PathToCompiledDir()))
|
||||
args = append(args, "-I", filepath.Join(outDir, fidlLib.PathToCompiledDir()))
|
||||
}
|
||||
for _, incdir := range info.Incdirs {
|
||||
args = append(args, "-I"+filepath.Join(dir, incdir))
|
||||
args = append(args, "-I", filepath.Join(srcDir, incdir))
|
||||
}
|
||||
|
||||
params := &extractParams{
|
||||
DeclarePrintf: true,
|
||||
DefineGlibcUse: true,
|
||||
|
Loading…
x
Reference in New Issue
Block a user