Skip to content
Permalink
Browse files

syz-manager: factor out rpc serving part

Update #605
  • Loading branch information...
dvyukov committed Dec 25, 2018
1 parent 4f7962a commit 85d28281fb84c829e7bf77a9e115e985bc8c665c
@@ -261,7 +261,7 @@ func splitTarget(target string) (string, string, string, error) {
return os, vmarch, arch, nil
}

func ParseEnabledSyscalls(target *prog.Target, enabled, disabled []string) (map[int]bool, error) {
func ParseEnabledSyscalls(target *prog.Target, enabled, disabled []string) ([]int, error) {
syscalls := make(map[int]bool)
if len(enabled) != 0 {
for _, c := range enabled {
@@ -296,7 +296,11 @@ func ParseEnabledSyscalls(target *prog.Target, enabled, disabled []string) (map[
if len(syscalls) == 0 {
return nil, fmt.Errorf("all syscalls are disabled by disable_syscalls in config")
}
return syscalls, nil
var arr []int
for id := range syscalls {
arr = append(arr, id)
}
return arr, nil
}

func matchSyscall(name, pattern string) bool {
@@ -20,13 +20,13 @@ type RPCServer struct {
s *rpc.Server
}

func NewRPCServer(addr string, receiver interface{}) (*RPCServer, error) {
func NewRPCServer(addr, name string, receiver interface{}) (*RPCServer, error) {
ln, err := net.Listen("tcp", addr)
if err != nil {
return nil, fmt.Errorf("failed to listen on %v: %v", addr, err)
}
s := rpc.NewServer()
if err := s.Register(receiver); err != nil {
if err := s.RegisterName(name, receiver); err != nil {
return nil, err
}
serv := &RPCServer{
@@ -57,7 +57,7 @@ func main() {

hub.initHTTP(cfg.HTTP)

s, err := rpctype.NewRPCServer(cfg.RPC, hub)
s, err := rpctype.NewRPCServer(cfg.RPC, "Hub", hub)
if err != nil {
log.Fatalf("failed to create rpc server: %v", err)
}
@@ -23,6 +23,7 @@ import (
"github.com/google/syzkaller/pkg/html"
"github.com/google/syzkaller/pkg/log"
"github.com/google/syzkaller/pkg/osutil"
"github.com/google/syzkaller/pkg/signal"
"github.com/google/syzkaller/prog"
)

@@ -101,14 +102,17 @@ func (mgr *Manager) collectStats() []UIStat {
mgr.mu.Lock()
defer mgr.mu.Unlock()

rawStats := mgr.stats.all()
stats := []UIStat{
{Name: "uptime", Value: fmt.Sprint(time.Since(mgr.startTime) / 1e9 * 1e9)},
{Name: "fuzzing", Value: fmt.Sprint(mgr.fuzzingTime / 60e9 * 60e9)},
{Name: "corpus", Value: fmt.Sprint(len(mgr.corpus)), Link: "/corpus"},
{Name: "triage queue", Value: fmt.Sprint(len(mgr.candidates))},
{Name: "cover", Value: fmt.Sprint(len(mgr.corpusCover)), Link: "/cover"},
{Name: "signal", Value: fmt.Sprint(mgr.corpusSignal.Len())},
{Name: "cover", Value: fmt.Sprint(rawStats["cover"]), Link: "/cover"},
{Name: "signal", Value: fmt.Sprint(rawStats["signal"])},
}
delete(rawStats, "cover")
delete(rawStats, "signal")
if mgr.checkResult != nil {
stats = append(stats, UIStat{
Name: "syscalls",
@@ -121,9 +125,7 @@ func (mgr *Manager) collectStats() []UIStat {
if !mgr.firstConnect.IsZero() {
secs = uint64(time.Since(mgr.firstConnect))/1e9 + 1
}

intStats := convertStats(mgr.stats.all(), secs)
intStats = append(intStats, convertStats(mgr.fuzzerStats, secs)...)
intStats := convertStats(rawStats, secs)
sort.Slice(intStats, func(i, j int) bool {
return intStats[i].Name < intStats[j].Name
})
@@ -254,8 +256,12 @@ func (mgr *Manager) httpCoverCover(w http.ResponseWriter, r *http.Request) {
}

func (mgr *Manager) httpCoverFallback(w http.ResponseWriter, r *http.Request) {
var maxSignal signal.Signal
for _, inp := range mgr.corpus {
maxSignal.Merge(inp.Signal.Deserialize())
}
calls := make(map[int][]int)
for s := range mgr.maxSignal {
for s := range maxSignal {
id, errno := prog.DecodeFallbackSignal(uint32(s))
calls[id] = append(calls[id], errno)
}
Oops, something went wrong.

0 comments on commit 85d2828

Please sign in to comment.
You can’t perform that action at this time.