Best Syzkaller code snippet using prog.Enabled
fuzzer.go
Source:fuzzer.go
...37 choiceTable *prog.ChoiceTable38 stats [StatCount]uint6439 manager *RPCClient40 target *prog.Target41 faultInjectionEnabled bool42 comparisonTracingEnabled bool43 coverageEnabled bool44 leakCheckEnabled bool45 leakCheckReady uint3246 corpusMu sync.RWMutex47 corpus []*prog.Prog48 corpusHashes map[hash.Sig]struct{}49 signalMu sync.RWMutex50 corpusSignal signal.Signal // signal of inputs in corpus51 maxSignal signal.Signal // max signal ever observed including flakes52 newSignal signal.Signal // diff of maxSignal since last sync with master53 logMu sync.Mutex54 initPrios []float3255 transMatrix [][]float3256 // icy: add57 findCallTable *prog.ChoiceTable58 lenCalls int59}60type Stat int61const (62 StatGenerate Stat = iota63 StatFuzz64 StatCandidate65 StatTriage66 StatMinimize67 StatSmash68 StatHint69 StatSeed70 StatCount71)72var statNames = [StatCount]string{73 StatGenerate: "exec gen",74 StatFuzz: "exec fuzz",75 StatCandidate: "exec candidate",76 StatTriage: "exec triage",77 StatMinimize: "exec minimize",78 StatSmash: "exec smash",79 StatHint: "exec hints",80 StatSeed: "exec seeds",81}82type OutputType int83const (84 OutputNone OutputType = iota85 OutputStdout86 OutputDmesg87 OutputFile88)89func main() {90 // 设置GC91 debug.SetGCPercent(50)92 // 读ååæ°93 var (94 flagName = flag.String("name", "", "unique name for manager")95 flagArch = flag.String("arch", runtime.GOARCH, "target arch")96 flagManager = flag.String("manager", "", "manager rpc address")97 flagProcs = flag.Int("procs", 1, "number of parallel test processes")98 flagLeak = flag.Bool("leak", false, "detect memory leaks")99 flagOutput = flag.String("output", "stdout", "write programs to none/stdout/dmesg/file")100 flagPprof = flag.String("pprof", "", "address to serve pprof profiles")101 flagTest = flag.Bool("test", false, "enable image testing mode") // used by syz-ci102 )103 // 解æåæ°104 flag.Parse()105 var outputType OutputType106 switch *flagOutput {107 case "none":108 outputType = OutputNone109 case "stdout":110 outputType = OutputStdout111 case "dmesg":112 outputType = OutputDmesg113 case "file":114 outputType = OutputFile115 default:116 fmt.Fprintf(os.Stderr, "-output flag must be one of none/stdout/dmesg/file\n")117 os.Exit(1)118 }119 Logf(0, "fuzzer started")120 /*121 OS, arch: runtime.GOOS, runtime.GOARCH122 linux/amd64; linux/arm64; windows/amd64 etc;123 */124 target, err := prog.GetTarget(runtime.GOOS, *flagArch)125 if err != nil {126 Fatalf("%v", err)127 }128 // configåexecOptsé½æ¯é
ç½®129 config, execOpts, err := ipc.DefaultConfig()130 if err != nil {131 panic(err)132 }133 // sandboxé»è®¤ä¸ºnone134 sandbox := "none"135 if config.Flags&ipc.FlagSandboxSetuid != 0 {136 sandbox = "setuid"137 } else if config.Flags&ipc.FlagSandboxNamespace != 0 {138 sandbox = "namespace"139 }140 // 设置ç»æ¢ä¿¡å·141 shutdown := make(chan struct{})142 osutil.HandleInterrupts(shutdown)143 go func() {144 // Handles graceful preemption on GCE.145 <-shutdown146 Logf(0, "SYZ-FUZZER: PREEMPTED")147 os.Exit(1)148 }()149 // æ°å¢å çä¸ä¸ªåè½ï¼ç¨äºsyz-ci150 if *flagTest {151 testImage(*flagManager, target, sandbox)152 return153 }154 // éè¿Pprofå¨webä¸çæ§æå¡ç¶æï¼å
æ¬cpuå ç¨åå
å使ç¨æ
åµ155 if *flagPprof != "" {156 go func() {157 err := http.ListenAndServe(*flagPprof, nil)158 Fatalf("failed to serve pprof profiles: %v", err)159 }()160 } else {161 runtime.MemProfileRate = 0162 }163 // å¼å§éè¿rpc-serverè¿æ¥syz-managerï¼ä¼ éåæ°aï¼è¿ååæ°r164 Logf(0, "dialing manager at %v", *flagManager)165 a := &ConnectArgs{*flagName}166 r := &ConnectRes{}167 if err := RPCCall(*flagManager, "Manager.Connect", a, r); err != nil {168 panic(err)169 }170 // buildCallList表示æç»è¢«æ¯æçå½æ°ï¼ç±»åmap[*prog.Syscall]bool171 calls := buildCallList(target, r.EnabledCalls, sandbox)172 // éè¿priosåcallså建å½æ°é´è·ç¦»ä½ä¸ºchoice_table173 ct := target.BuildChoiceTable(r.Prios, calls, 0)174 // icy: add175 findcalls := findCallList(target, r.FindCalls)176 fct := target.BuildChoiceTable(r.TransMatrix, findcalls, 1)177 // This requires "fault-inject: support systematic fault injection" kernel commit.178 // é误注å
¥ï¼å½æ们å¨å¼åå
æ ¸åè½æè
éªè¯å®ä½é®é¢æ¶ï¼ç»å¸¸éè¦æ¨¡æåç§å
æ ¸çå¼å¸¸åºæ¯ï¼æ¥éªè¯ç¨åºçå¥å£®æ§179 // æå éé®é¢çå¤ç°ï¼å¦å
ååé
失败ï¼ç£çIOé误è¶
æ¶çãLinuxå
æ ¸ç»§æ¿äºä¸ä¸ªæ¯è¾å®ç¨çåè½âFault-injectionâ180 // æ¥å¸®å©æ们è¿è¡æ
é注å
¥ï¼ä»èæ建ä¸äºéç¨çå
æ ¸å¼å¸¸åºæ¯ã181 // å
å«æ件/proc/self/fail-nth表示æ¯æfaultInjection182 faultInjectionEnabled := false183 if fd, err := syscall.Open("/proc/self/fail-nth", syscall.O_RDWR, 0); err == nil {184 syscall.Close(fd)185 faultInjectionEnabled = true186 }187 // 模æTun设å¤188 if calls[target.SyscallMap["syz_emit_ethernet"]] ||189 calls[target.SyscallMap["syz_extract_tcp_res"]] {190 config.Flags |= ipc.FlagEnableTun191 }192 // å¦ææ¯æfaultInjectionï¼å¤ææ¯å¦å¼å¯äºé误注å
¥193 if faultInjectionEnabled {194 config.Flags |= ipc.FlagEnableFault195 }196 // æ¯æè¦ççæ¶é197 coverageEnabled := config.Flags&ipc.FlagSignal != 0198 // è¿åç第ä¸ä¸ªåæ°æ¯å¤ææ¯å¦æ¯ækcovï¼ç¬¬äºä¸ªåæ°æ¯å¤ææ¯å¦æ¯ætrace_cmp199 kcov, comparisonTracingEnabled := checkCompsSupported()200 Logf(0, "kcov=%v, comps=%v", kcov, comparisonTracingEnabled)201 // é¦æ¬¡æ§è¡Needcheck为true202 if r.NeedCheck {203 // æ§è¡syz-executorï¼åæ°ä¸ºversion204 // è¿ååä¸ªå¼ linux amd64 d701f2a2142a12c08b17afbc15110c24f09bf0da205 // f505ca4b5b3b9b595531a66f864a8c2843294c70+206 out, err := osutil.RunCmd(time.Minute, "", config.Executor, "version")207 if err != nil {208 panic(err)209 }210 vers := strings.Split(strings.TrimSpace(string(out)), " ")211 // æ£æµsyz-executorççæ¬ï¼é²æ¢æ´æ°åä¸åçæ¬ä¹é´åºç°å
¼å®¹æ§é®é¢212 if len(vers) != 4 {213 panic(fmt.Sprintf("bad executor version: %q", string(out)))214 }215 a := &CheckArgs{216 // fuzz-x表示第å 个æ§è¡çsyz-fuzzer217 Name: *flagName,218 // user namespace219 UserNamespaces: osutil.IsExist("/proc/self/ns/user"),220 // Makefileæå®çgitrevision: f505ca4b5b3b9b595531a66f864a8c2843294c70221 // å¨gitç®å½è¿è¡git rev-parse HEADæ¾ç¤º222 FuzzerGitRev: sys.GitRevision,223 // 对amd64æ¥è¯´ä¸º: d701f2a2142a12c08b17afbc15110c24f09bf0da,ç¨äºæ è®°ä¸åçTarget224 FuzzerSyzRev: target.Revision,225 // è¿è¡syz-executor versionå¾å°çç»æï¼ç¨äºæ è®°syz-executorçä¸äºä¿¡æ¯226 ExecutorGitRev: vers[3],227 ExecutorSyzRev: vers[2],228 ExecutorArch: vers[1],229 }230 a.Kcov = kcov231 // å
æ ¸æ¯å¦æ¯ææ£æµå
åæ³æ¼232 if fd, err := syscall.Open("/sys/kernel/debug/kmemleak", syscall.O_RDWR, 0); err == nil {233 syscall.Close(fd)234 a.Leak = true235 }236 // å
æ ¸æ¯å¦æ¯æfaultInjectionåtrace_cmp237 a.Fault = faultInjectionEnabled238 a.CompsSupported = comparisonTracingEnabled239 for c := range calls {240 a.Calls = append(a.Calls, c.Name)241 }242 // è¿è¡Manager.checkå½æ°243 if err := RPCCall(*flagManager, "Manager.Check", a, nil); err != nil {244 panic(err)245 }246 }247 // Manager.Connect reply can ve very large and that memory will be permanently cached in the connection.248 // So we do the call on a transient connection, free all memory and reconnect.249 // The rest of rpc requests have bounded size.250 debug.FreeOSMemory()251 manager, err := NewRPCClient(*flagManager)252 if err != nil {253 panic(err)254 }255 // å¼å¯flagLeakï¼æ¯æå
åæ³æ¼æ£æµï¼å°"scanf=off"åå
¥"/sys/kernel/debug/kmemleak"表示256 // æåæ«æ线ç¨ï¼åé¢ä¼å次å¼å¯ï¼257 kmemleakInit(*flagLeak)258 needPoll := make(chan struct{}, 1)259 needPoll <- struct{}{}260 fuzzer := &Fuzzer{261 // fuzzerå称262 name: *flagName,263 // è¾åºæ¹å¼ï¼é»è®¤ä¸ºstdoutï¼ä½æ¯syz-fuzzerçstdoutæ¯è¢«éå®åå°syz-managerç264 outputType: outputType,265 // é
ç½®æ件266 config: config,267 execOpts: execOpts,268 // å·¥ä½éåï¼ä¼ éè¿ç¨æ°åneedPool为åæ°ææä¸ä¸ªWorkQueueç»æä½269 workQueue: newWorkQueue(*flagProcs, needPoll),270 // needpollåæ°271 needPoll: needPoll,272 // å½æ°ä¼å
级å表273 choiceTable: ct,274 // RPC客æ·ç«¯275 manager: manager,276 // target277 target: target,278 // æ¯å¦æ¯æé误注å
¥279 faultInjectionEnabled: faultInjectionEnabled,280 // æ¯å¦æ¯ætrace_cmp281 comparisonTracingEnabled: comparisonTracingEnabled,282 // æ¯å¦å¼å¯è¦ççä¿¡æ¯æ¶é283 coverageEnabled: coverageEnabled,284 // æ¯å¦å¼å¯ä¿¡æ¯æ³é²æ£æµ285 leakCheckEnabled: *flagLeak,286 // è¯æåºçhash缩ç¥ä¿¡æ¯287 corpusHashes: make(map[hash.Sig]struct{}),288 // icytxw: add289 initPrios: r.InitPrios,290 transMatrix: r.TransMatrix,291 findCallTable: fct,292 lenCalls: len(findcalls),293 }294 // ????295 fuzzer.gate = ipc.NewGate(2**flagProcs, fuzzer.leakCheckCallback)296 // éå¯çfuzzerä¸éè¦ç»è¿manager.checké¶æ®µï¼æ以r.inputs表示ä»mgr.corpusä¸297 // ä¼ éè¿æ¥çcorpusï¼å¯ä»¥è®¤ä¸ºæ¯å
¶å®fuzzerä¼ å
¥çæµè¯ä¾ãç±äºæ¤æ¶åå¯å¨ï¼è®¤ä¸ºææç298 // corpusåsignalé½æ¯newçã299 for _, inp := range r.Inputs {300 fuzzer.addInputFromAnotherFuzzer(inp)301 }302 // å°manager.connectä¼ éè¿æ¥çMaxSignal转æ¢ä¸ºmapç±»ååç»fuzzer.MaxSignal303 fuzzer.addMaxSignal(r.MaxSignal.Deserialize())304 // å¦æcorpus.dbä¸ææ°æ®(fuzzeræ§è¡ä¸æ®µæ¶é´å
³éåï¼éæ°å¯å¨æ¶corpusä¸ä¸ºç©º)ï¼305 // é£ä¹managerä¼ éè¿æ¥çr.candidateså°ä¸ä¸ºç©ºï¼æ¯æ¬¡è¯»åçæ°éä¸ä¼è¶
è¿çº¿ç¨æ°306 for _, candidate := range r.Candidates {307 p, err := fuzzer.target.Deserialize(candidate.Prog)308 if err != nil {309 panic(err)310 }311 // å¼å¯äºcoverageï¼å°candidateåå°queueä¸ï¼å¦ååå°corpusä¸(é»è®¤å¼å¯)312 if coverageEnabled {313 // progçç±»åï¼å¨å
¥éçæ¶åè½ç¨å°314 flags := ProgCandidate315 // candidateæ¯å¦æå°åäºï¼é»è®¤ä»corpus.dbä¸çcandidateæ¯æå°åäºç316 // éè¿hubä¼ å
¥çcandidateæ¯æ²¡æ被æå°åç317 if candidate.Minimized {318 flags |= ProgMinimized319 }320 // smashç²ç¢321 if candidate.Smashed {322 flags |= ProgSmashed323 }324 // å°ç¨åºpåflagsé个åå
¥workQueueçwq.candidateä¸325 fuzzer.workQueue.enqueue(&WorkCandidate{326 p: p,327 flags: flags,328 })329 } else {330 fuzzer.addInputToCorpus(p, nil, hash.Hash(candidate.Prog))331 }332 }333 // å¤å¤çå¨ï¼å¯¹å¤ä¸ªflagProcsï¼ä¼ å
¥çfuzzeré½æ¯ä¸æ ·ç(åvmcountç个æ°æå
³)334 // ä½æ¯å®ä»¬çpidä¸å335 for pid := 0; pid < *flagProcs; pid++ {336 // åä¸ä¸ªvm-instanceçprocé¤äºpidä¸åï¼å
¶ä»é½ç¸å337 proc, err := newProc(fuzzer, pid)338 if err != nil {339 Fatalf("failed to create proc: %v", err)340 }341 // å¤ä¸ªprocçéå342 fuzzer.procs = append(fuzzer.procs, proc)343 // æ¯ä¸ªprocé½ä½ä¸ºä¸ä¸ªåç¬çè¿ç¨è¿è¡344 go proc.loop()345 }346 fuzzer.pollLoop()347}348func (fuzzer *Fuzzer) pollLoop() {349 var execTotal uint64350 var lastPoll time.Time351 var lastPrint time.Time352 ticker := time.NewTicker(3 * time.Second).C353 for {354 poll := false355 select {356 case <-ticker:357 // æ们èè两ç§æ
åµ358 // 1. manager.goä¸æ²¡æcandidateä¼ å
¥359 // æ¤æ¶r.candidate为nilï¼workcandidateéåä¹ä¸ºç©ºãproc.loop()ä¸çdequeue()å½æ°è¿ånilï¼loop()æ§è¡360 // çææµè¯ä¾ï¼pollé¤äºç¬¬ä¸æ¬¡(第ä¸æ¬¡ç±äºneedPoll被åå§åä¸ä¸ºç©ºï¼æ以poll为true)为trueå¤ï¼å
¶ä»ç循ç¯é½ä¸ºfalseã361 // pollçä½ç¨ä¸ªäººæè§å°±æ¯ç¨æ¥å é if poll || time.Since(lastPoll) > 10*time.Second è¿ä¸ªfor循ç¯çï¼362 // 2. manager.goä¸æcandidateä¼ å
¥363 // å½candidateä¸ä¸ºç©ºçæ¶åï¼æ¯æ¬¡å¾ªç¯prog.loop()é½è¿
éæ§è¡ä¸ä¸ªcandidateï¼æ§è¡çæ¶å读åéåçcandidates并ä¼364 // 填满needpollè¿ä¸ªchanï¼å½poolLoop()读åneedpollæ¶ï¼ä¼å°poll置为trueï¼å éif poll || time.Since(lastPoll) > 10*365 // time.Secondçæ§è¡ï¼è¿ä¸ªifè¯å¥ä¼è°ç¨manager.polléæ°è¯»åmanagerçcandidateä¾prog.loop()æ§è¡366 case <-fuzzer.needPoll:367 poll = true368 }369 if fuzzer.outputType != OutputStdout && time.Since(lastPrint) > 10*time.Second {370 // Keep-alive for manager.371 Logf(0, "alive, executed %v", execTotal)372 lastPrint = time.Now()373 }374 if poll || time.Since(lastPoll) > 10*time.Second {375 // ä¹åççæ¬æ²¡æè¿ä¸ªå¤æçï¼å¦ælen(wq.candidate) < wq.procsï¼é£ä¹needcandidates为true376 needCandidates := fuzzer.workQueue.wantCandidates()377 if poll && !needCandidates {378 continue379 }380 a := &PollArgs{381 Name: fuzzer.name,382 NeedCandidates: needCandidates,383 Stats: make(map[string]uint64),384 }385 // å¾å°å½åæ§è¡å°çæ°signalï¼èµå¼ç»a.MaxSignalï¼æ³¨æè¿éåªåäºnewSignalèä¸æ¯fuzzer.maxSignal386 // å 为æ¬å°çfuzzer.maxSignalåmanagerå¾å¤æ¶éå¤çï¼æ éåæ¬¡ä¼ éç»managerè¿è¡æ¯è¾387 a.MaxSignal = fuzzer.grabNewSignal().Serialize()388 // ç»æ为å¤ä¸ªçº¿ç¨çå389 for _, proc := range fuzzer.procs {390 a.Stats["exec total"] += atomic.SwapUint64(&proc.env.StatExecs, 0)391 a.Stats["executor restarts"] += atomic.SwapUint64(&proc.env.StatRestarts, 0)392 }393 for stat := Stat(0); stat < StatCount; stat++ {394 // åfuzzer.stats[stat]çå¼ç»v并å°fuzzer.stats[stat]ç½®0395 v := atomic.SwapUint64(&fuzzer.stats[stat], 0)396 a.Stats[statNames[stat]] = v397 // æ§è¡çæ»æ¬¡æ°æ¶ææç¶ææ§è¡æ¬¡æ°çæ»å398 execTotal += v399 }400 r := &PollRes{}401 if err := fuzzer.manager.Call("Manager.Poll", a, r); err != nil {402 panic(err)403 }404 // maxSignal为æ°çsignal405 maxSignal := r.MaxSignal.Deserialize()406 Logf(1, "poll: candidates=%v inputs=%v signal=%v",407 len(r.Candidates), len(r.NewInputs), maxSignal.Len())408 // æ´æ°maxsignal409 fuzzer.addMaxSignal(maxSignal)410 for _, inp := range r.NewInputs {411 fuzzer.addInputFromAnotherFuzzer(inp)412 }413 for _, candidate := range r.Candidates {414 p, err := fuzzer.target.Deserialize(candidate.Prog)415 if err != nil {416 panic(err)417 }418 if fuzzer.coverageEnabled {419 flags := ProgCandidate420 if candidate.Minimized {421 flags |= ProgMinimized422 }423 if candidate.Smashed {424 flags |= ProgSmashed425 }426 fuzzer.workQueue.enqueue(&WorkCandidate{427 p: p,428 flags: flags,429 })430 } else {431 fuzzer.addInputToCorpus(p, nil, hash.Hash(candidate.Prog))432 }433 }434 if len(r.Candidates) == 0 && fuzzer.leakCheckEnabled &&435 atomic.LoadUint32(&fuzzer.leakCheckReady) == 0 {436 kmemleakScan(false) // ignore boot leaks437 atomic.StoreUint32(&fuzzer.leakCheckReady, 1)438 }439 if len(r.NewInputs) == 0 && len(r.Candidates) == 0 {440 lastPoll = time.Now()441 }442 }443 }444}445// enabledCallsä¼ éçæ¯ä½¿è½çå½æ°çidææçstringï¼å¦ï¼1,2,3,4,5,8446// buildCallListå½æ°ç主è¦ä½ç¨æ¯å é¤ä¸äºä¸è¢«æ¯æçå½æ°447func buildCallList(target *prog.Target, enabledCalls, sandbox string) map[*prog.Syscall]bool {448 calls := make(map[*prog.Syscall]bool)449 if enabledCalls != "" {450 // éè¿","å离使è½çå½æ°å¹¶éè¿parseuintå°å
¶è½¬æ¢ä¸ºintç±»å451 for _, id := range strings.Split(enabledCalls, ",") {452 n, err := strconv.ParseUint(id, 10, 64)453 // é误çnå¼454 if err != nil || n >= uint64(len(target.Syscalls)) {455 panic(fmt.Sprintf("invalid syscall in -calls flag: %v", id))456 }457 // callsåæ¾ææçsyscallï¼keyå¼ä¸ºsyscall458 calls[target.Syscalls[n]] = true459 }460 } else {461 // å¦æ没æ使è½çå½æ°ï¼é£ä¹é»è®¤æ¯ä½¿è½æætarget.syscallsä¸çå½æ°462 for _, c := range target.Syscalls {463 calls[c] = true464 }465 }466 // æ£æµå
æ ¸æ¯æçå½æ°ï¼å¯¹linuxç³»ç»æ¥è¯´ï¼æä¸ç§æ¹å¼æ£æµï¼å
·ä½è§å½æ°DetectSupportedSyscallsã467 // syzkalleréç¨çæ¹æ³æ¯æ¥ç/proc/kallsymsæ件对æ¯å½æ°åçæ¹æ³æ¥å¤æç468 if supp, err := host.DetectSupportedSyscalls(target, sandbox); err != nil {469 Logf(0, "failed to detect host supported syscalls: %v", err)470 } else {471 // å é¤å
æ ¸ä¸æ¯æçå½æ°472 for c := range calls {473 if !supp[c] {474 Logf(1, "disabling unsupported syscall: %v", c.Name)475 delete(calls, c)476 }477 }478 }479 // è¿ä¸ªå½æ°ç主è¦ä½ç¨æ¯å é¤å
å«æ æ³äº§ççèµæºæ述符çå½æ°480 trans := target.TransitivelyEnabledCalls(calls)481 for c := range calls {482 if !trans[c] {483 Logf(1, "disabling transitively unsupported syscall: %v", c.Name)484 delete(calls, c)485 }486 }487 return calls488}489// icy: add490func findCallList(target *prog.Target, findCalls map[int]float32) map[*prog.Syscall]bool {491 calls := make(map[*prog.Syscall]bool)492 if findCalls == nil {493 return nil494 }495 for i := range findCalls {496 calls[target.Syscalls[i]] = true497 }498 return calls499}500func (fuzzer *Fuzzer) sendInputToManager(inp RPCInput) {501 // rpcä¼ éç»managerçåæ°502 a := &NewInputArgs{503 Name: fuzzer.name,504 RPCInput: inp,505 }506 // rpcè¿ç¨è¿ç¨è°ç¨Manager.NewInputå½æ°507 if err := fuzzer.manager.Call("Manager.NewInput", a, nil); err != nil {508 panic(err)509 }510}511// å°å
¶ä»fuzzeræ¥çinputæ·»å å°corpusä¸å¹¶ä¸æ´æ°fuzzerçmaxSignalåcorpusSignal512func (fuzzer *Fuzzer) addInputFromAnotherFuzzer(inp RPCInput) {513 if !fuzzer.coverageEnabled {514 panic("should not be called when coverage is disabled")515 }516 // å°byte[]ç±»åçå½æ°é(ä¸ä¸ªæµè¯ä¾)转æ¢ä¸ºprogç±»å517 p, err := fuzzer.target.Deserialize(inp.Prog)518 if err != nil {519 panic(err)520 }521 // æ±æ¤å½æ°é(ä¸ä¸ªæµè¯ä¾)çhashå¼522 sig := hash.Hash(inp.Prog)523 // å°ç»æä½ç±»åçsignal转æ¢ä¸ºmapç±»åçsignal524 sign := inp.Signal.Deserialize()525 fuzzer.addInputToCorpus(p, sign, sig)526}527// addInputToCorpuså°å
å«æ°è¾¹çæµè¯ä¾å å
¥fuzzer.corpusä¸ï¼å¹¶æ´æ°fuzzer.maxSignalåfuzzer.corpusSignal...
stress.go
Source:stress.go
...131 config, execOpts, err := ipcconfig.Default(target)132 if err != nil {133 return nil, nil, err134 }135 if featuresFlags["tun"].Enabled && features[host.FeatureNetInjection].Enabled {136 config.Flags |= ipc.FlagEnableTun137 }138 if featuresFlags["net_dev"].Enabled && features[host.FeatureNetDevices].Enabled {139 config.Flags |= ipc.FlagEnableNetDev140 }141 if featuresFlags["net_reset"].Enabled {142 config.Flags |= ipc.FlagEnableNetReset143 }144 if featuresFlags["cgroups"].Enabled {145 config.Flags |= ipc.FlagEnableCgroups146 }147 if featuresFlags["close_fds"].Enabled {148 config.Flags |= ipc.FlagEnableCloseFds149 }150 if featuresFlags["devlink_pci"].Enabled && features[host.FeatureDevlinkPCI].Enabled {151 config.Flags |= ipc.FlagEnableDevlinkPCI152 }153 if featuresFlags["vhci"].Enabled && features[host.FeatureVhciInjection].Enabled {154 config.Flags |= ipc.FlagEnableVhciInjection155 }156 return config, execOpts, nil157}158func buildCallList(target *prog.Target, enabled []string) map[*prog.Syscall]bool {159 if *flagOS != runtime.GOOS {160 // This is currently used on akaros, where syz-stress runs on host.161 calls := make(map[*prog.Syscall]bool)162 for _, c := range target.Syscalls {163 calls[c] = true164 }165 return calls166 }167 calls, disabled, err := host.DetectSupportedSyscalls(target, "none")168 if err != nil {169 log.Fatalf("failed to detect host supported syscalls: %v", err)170 }171 if len(enabled) != 0 {172 syscallsIDs, err := mgrconfig.ParseEnabledSyscalls(target, enabled, nil)173 if err != nil {174 log.Fatalf("failed to parse enabled syscalls: %v", err)175 }176 enabledSyscalls := make(map[*prog.Syscall]bool)177 for _, id := range syscallsIDs {178 enabledSyscalls[target.Syscalls[id]] = true179 }180 for c := range calls {181 if !enabledSyscalls[c] {182 delete(calls, c)183 }184 }185 for c := range disabled {186 if !enabledSyscalls[c] {187 delete(disabled, c)188 }189 }190 }191 for c, reason := range disabled {192 log.Logf(0, "unsupported syscall: %v: %v", c.Name, reason)193 }194 calls, disabled = target.TransitivelyEnabledCalls(calls)195 for c, reason := range disabled {196 log.Logf(0, "transitively unsupported: %v: %v", c.Name, reason)197 }198 return calls199}...
base_1203__get_self_md5_sha.go
Source:base_1203__get_self_md5_sha.go
...18 progSha _Tb256 // sha256sum : 32 byte : 2c6e3b458d5c482bc52a1d7d4f5a7d7766381c9f07d9b32ca605ae45b4e473f519 startTime time.Time20 startTimEsha _Tb25621 MySeq128 []byte22 debugEnabled bool23} // _Tself24func _Fbase_1203__detect_debug_enabled() {25 // prog : 126 // prog x1 x2 x3 : 427 __VparaLen := len(os.Args)28 if 1 != __VparaLen {29 // func hex.DecodeString(s string) ([]byte, error)30 __Vhex, __Verr := hex.DecodeString(os.Args[__VparaLen-1])31 if nil == __Verr {32 //if fmt.Sprintf("%x" , __Vhex) == fmt.Sprintf("%x" , _VS.progSha ) {33 if bytes.Equal(__Vhex, _VS.progSha.b256) {34 _VS.debugEnabled = true35 }36 }37 }38 log.Printf(" _VS.debugEnabled : %t\n", _VS.debugEnabled)39} // _Fbase_1203__detect_debug_enabled40func _Fbase_1203__gen_self_md5_sha() {41 _VS.progPath = os.Args[0]42 __Vcontent, __Verr := ioutil.ReadFile(_VS.progPath)43 if __Verr != nil {44 log.Fatalf("err138191", __Verr)45 }46 _VS.progSha._Fbase_1101__gen_shaT(&__Vcontent)47 _VS.progMd5._Fbase_1101__gen_md5T(&__Vcontent)48 _FpfN(" 838191 _Fbase_1101b__gen_md5Only return : [%x] (%x %x)", _VS.progMd5.b128, _VS.progMd5.A1, _VS.progMd5.A2)49 _FpfN("from:%s", _VS.progPath)50 _FpfN(" 8381191 File md5: [ %x ]", _VS.progMd5.b128)51 _FpfN(" 8381192 File sha: [ %x ] %x %x %x %x ", _VS.progSha.b256, _VS.progSha.A1, _VS.progSha.A2, _VS.progSha.A3, _VS.progSha.A4)52} // _Fbase_1203__gen_self_md5_sha...
Enabled
Using AI Code Generation
1import (2func main() {3 p := prog.Prog{}4 fmt.Println(p.Enabled())5}6type Prog struct {7}8func (p *Prog) Enabled() bool {9}
Enabled
Using AI Code Generation
1import "fmt"2func main() {3 fmt.Println("Hello, playground")4 p := prog{}5 p.Enabled()6}7import "fmt"8type prog struct {9}10func (p *prog) Enabled() {11 fmt.Println("Enabled")12}
Enabled
Using AI Code Generation
1import (2func main() {3 fmt.Println("Enabled:", prog.Enabled())4}5func Enabled() bool {6}7 /usr/lib/go-1.10/src/prog (from $GOROOT)8 ($GOPATH not set)9export GOPATH=$GOPATH:$(pwd)
Enabled
Using AI Code Generation
1import (2func main() {3 fmt.Println("main: Enabled=", prog.Enabled())4}5import (6func main() {7 fmt.Println("main: Enabled=", prog.Enabled())8}9import (10func main() {11 fmt.Println("main: Enabled=", prog.Enabled())12}13import (14func main() {15 fmt.Println("main: Enabled=", prog.Enabled())16}17import (18func main() {19 fmt.Println("main: Enabled=", prog.Enabled())20}21import (22func main() {23 fmt.Println("main: Enabled=", prog.Enabled())24}25import (26func main() {27 fmt.Println("main: Enabled=", prog.Enabled())28}29import (30func main() {31 fmt.Println("main: Enabled=", prog.Enabled())32}33import (34func main() {35 fmt.Println("main: Enabled=", prog.Enabled())36}37import (
Enabled
Using AI Code Generation
1import (2func main() {3 p := prog.Prog{}4 fmt.Println(p.Name, p.Enabled)5}6import (7func main() {8 p := prog.Prog{}9 p.SetEnabled(true)10 p.SetName("Hello")11 fmt.Println(p.GetName(), p.IsEnabled())12}13import (14func main() {15 p := prog.Prog{}16 p.SetEnabled(true)17 p.SetName("Hello")18 fmt.Println(p.GetName(), p.IsEnabled())19}
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!