syzkaller: Index | Files

package csource

import ""

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


Package Files

build.go common.go csource.go generated.go options.go

func Build Uses

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 Uses

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 BuildNoWarn Uses

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

BuildNoWarn is the same as Build, but ignores all compilation warnings. Should not be used in tests, but may be used e.g. when we are bisecting and potentially using an old repro with newer compiler, or a compiler that we never seen before. In these cases it's more important to build successfully.

func Format Uses

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

Format reformats C source using clang-format.

func PrintAvailableFeaturesFlags Uses

func PrintAvailableFeaturesFlags()

func Write Uses

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

type Feature Uses

type Feature struct {
    Description string
    Enabled     bool

type Features Uses

type Features map[string]Feature

func ParseFeaturesFlags Uses

func ParseFeaturesFlags(enable, disable string, defaultValue bool) (Features, error)

type Options Uses

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"`

    Leak bool `json:"leak,omitempty"` // do leak checking

    // These options allow for a more fine-tuned control over the generated C code.
    NetInjection bool `json:"tun,omitempty"`
    NetDevices   bool `json:"netdev,omitempty"`
    NetReset     bool `json:"resetnet,omitempty"`
    Cgroups      bool `json:"cgroups,omitempty"`
    BinfmtMisc   bool `json:"binfmt_misc,omitempty"`
    CloseFDs     bool `json:"close_fds"`
    KCSAN        bool `json:"kcsan,omitempty"`
    DevlinkPCI   bool `json:"devlinkpci,omitempty"`
    USB          bool `json:"usb,omitempty"`

    UseTmpDir  bool `json:"tmpdir,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 Uses

func DefaultOpts(cfg *mgrconfig.Config) Options

func DeserializeOptions Uses

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

func (Options) Check Uses

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 Uses

func (opts Options) Serialize() []byte

Package csource imports 14 packages (graph) and is imported by 14 packages. Updated 2020-07-06. Refresh now. Tools for package owners.