csource

package
v0.0.0-...-5d42abc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 9, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package csource generates [almost] equivalent C programs from syzkaller programs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Build

func Build(target *prog.Target, src []byte) (string, error)

Build builds a C program from source src and returns name of the resulting binary.

func BuildFile

func BuildFile(target *prog.Target, src string) (string, error)

BuildFile builds a C/C++ program from file src and returns name of the resulting binary.

func Format

func Format(src []byte) ([]byte, error)

Format reformats C source using clang-format.

func Write

func Write(p *prog.Prog, opts Options) ([]byte, error)

Types

type Options

type Options struct {
	Threaded    bool   `json:"threaded,omitempty"`
	Collide     bool   `json:"collide,omitempty"`
	Repeat      bool   `json:"repeat,omitempty"`
	RepeatTimes int    `json:"repeat_times,omitempty"` // if non-0, repeat that many times
	Procs       int    `json:"procs"`
	Sandbox     string `json:"sandbox"`

	Fault     bool `json:"fault,omitempty"` // inject fault into FaultCall/FaultNth
	FaultCall int  `json:"fault_call,omitempty"`
	FaultNth  int  `json:"fault_nth,omitempty"`

	// These options allow for a more fine-tuned control over the generated C code.
	EnableTun     bool `json:"tun,omitempty"`
	UseTmpDir     bool `json:"tmpdir,omitempty"`
	EnableCgroups bool `json:"cgroups,omitempty"`
	EnableNetdev  bool `json:"netdev,omitempty"`
	ResetNet      bool `json:"resetnet,omitempty"`
	HandleSegv    bool `json:"segv,omitempty"`

	// Generate code for use with repro package to prints log messages,
	// which allows to detect hangs.
	Repro bool `json:"repro,omitempty"`
	Trace bool `json:"trace,omitempty"`
}

Options control various aspects of source generation. Dashboard also provides serialized Options along with syzkaller reproducers.

func DefaultOpts

func DefaultOpts(cfg *mgrconfig.Config) Options

func DeserializeOptions

func DeserializeOptions(data []byte) (Options, error)

func (Options) Check

func (opts Options) Check(OS string) error

Check checks if the opts combination is valid or not. For example, Collide without Threaded is not valid. Invalid combinations must not be passed to Write.

func (Options) Serialize

func (opts Options) Serialize() []byte

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL