ipc

package
v0.0.0-...-af24b05 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: Apache-2.0 Imports: 15 Imported by: 90

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FlagsToSandbox

func FlagsToSandbox(flags EnvFlags) string

Types

type CallFlags

type CallFlags uint32
const (
	CallExecuted      CallFlags = 1 << iota // was started at all
	CallFinished                            // finished executing (rather than blocked forever)
	CallBlocked                             // finished but blocked during execution
	CallFaultInjected                       // fault was injected into this call
)

type CallInfo

type CallInfo struct {
	Flags  CallFlags
	Signal []uint32 // feedback signal, filled if FlagSignal is set
	Cover  []uint32 // per-call coverage, filled if FlagSignal is set and cover == true,
	// if dedup == false, then cov effectively contains a trace, otherwise duplicates are removed
	Comps prog.CompMap // per-call comparison operands
	Errno int          // call errno (0 if the call was successful)
}

type Config

type Config struct {
	// Path to executor binary.
	Executor string

	UseShmem      bool // use shared memory instead of pipes for communication
	UseForkServer bool // use extended protocol with handshake
	RateLimit     bool // rate limit start of new processes for host fuzzer mode

	// Flags are configuation flags, defined above.
	Flags      EnvFlags
	SandboxArg int

	Timeouts targets.Timeouts
}

Config is the configuration for Env.

type Env

type Env struct {
	// contains filtered or unexported fields
}

func MakeEnv

func MakeEnv(config *Config, pid int) (*Env, error)

func (*Env) Close

func (env *Env) Close() error

func (*Env) Exec

func (env *Env) Exec(opts *ExecOpts, p *prog.Prog) (output []byte, info *ProgInfo, hanged bool, err0 error)

func (*Env) ExecProg

func (env *Env) ExecProg(opts *ExecOpts, progData []byte) (output []byte, info *ProgInfo, hanged bool, err0 error)

Exec starts executor binary to execute program stored in progData in exec encoding and returns information about the execution: output: process output info: per-call info hanged: program hanged and was killed err0: failed to start the process or bug in executor itself.

func (*Env) ForceRestart

func (env *Env) ForceRestart()

func (*Env) RestartIfNeeded

func (env *Env) RestartIfNeeded() error

RestartIfNeeded brings up an executor process if it was stopped.

type EnvFlags

type EnvFlags uint64

Configuration flags for Config.Flags.

const (
	FlagDebug               EnvFlags = 1 << iota // debug output from executor
	FlagSignal                                   // collect feedback signals (coverage)
	FlagSandboxSetuid                            // impersonate nobody user
	FlagSandboxNamespace                         // use namespaces for sandboxing
	FlagSandboxAndroid                           // use Android sandboxing for the untrusted_app domain
	FlagExtraCover                               // collect extra coverage
	FlagEnableTun                                // setup and use /dev/tun for packet injection
	FlagEnableNetDev                             // setup more network devices for testing
	FlagEnableNetReset                           // reset network namespace between programs
	FlagEnableCgroups                            // setup cgroups for testing
	FlagEnableCloseFds                           // close fds after each program
	FlagEnableDevlinkPCI                         // setup devlink PCI device
	FlagEnableVhciInjection                      // setup and use /dev/vhci for hci packet injection
	FlagEnableWifi                               // setup and use mac80211_hwsim for wifi emulation
	FlagDelayKcovMmap                            // manage kcov memory in an optimized way
	FlagEnableNicVF                              // setup NIC VF device
)

Note: New / changed flags should be added to parse_env_flags in executor.cc.

func SandboxToFlags

func SandboxToFlags(sandbox string) (EnvFlags, error)

type ExecFlags

type ExecFlags uint64

Per-exec flags for ExecOpts.Flags.

const (
	FlagCollectSignal        ExecFlags = 1 << iota // collect feedback signals
	FlagCollectCover                               // collect coverage
	FlagDedupCover                                 // deduplicate coverage in executor
	FlagCollectComps                               // collect KCOV comparisons
	FlagThreaded                                   // use multiple threads to mitigate blocked syscalls
	FlagEnableCoverageFilter                       // setup and use bitmap to do coverage filter
)

type ExecOpts

type ExecOpts struct {
	Flags ExecFlags
}

type Gate

type Gate struct {
	// contains filtered or unexported fields
}

Gate limits concurrency level and window to the given value. Limitation of concurrency window means that if a very old activity is still running it will not let new activities to start even if concurrency level is low.

func NewGate

func NewGate(c int, f func()) *Gate

If f is not nil, it will be called after each batch of c activities.

func (*Gate) Enter

func (g *Gate) Enter() int

func (*Gate) Leave

func (g *Gate) Leave(idx int)

type ProgInfo

type ProgInfo struct {
	Calls     []CallInfo
	Extra     CallInfo      // stores Signal and Cover collected from background threads
	Elapsed   time.Duration // total execution time of the program
	Freshness int           // number of programs executed in the same process before this one
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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