How to use IsSpecial method of prog Package

Best Syzkaller code snippet using prog.IsSpecial

analysis.go

Source:analysis.go Github

copy

Full Screen

...50 ForeachArg(c, func(arg Arg, _ *ArgCtx) {51 switch a := arg.(type) {52 case *PointerArg:53 switch {54 case a.IsSpecial():55 case a.VmaSize != 0:56 s.va.noteAlloc(a.Address/s.target.PageSize, a.VmaSize/s.target.PageSize)57 case a.Res != nil:58 s.ma.noteAlloc(a.Address, a.Res.Size())59 }60 }61 switch typ := arg.Type().(type) {62 case *ResourceType:63 a := arg.(*ResultArg)64 if resources && a.Dir() != DirIn {65 s.resources[typ.Desc.Name] = append(s.resources[typ.Desc.Name], a)66 // TODO: negative PIDs and add them as well (that's process groups).67 }68 case *BufferType:69 a := arg.(*DataArg)70 if a.Dir() != DirOut && len(a.Data()) != 0 {71 val := string(a.Data())72 // Remove trailing zero padding.73 for len(val) >= 2 && val[len(val)-1] == 0 && val[len(val)-2] == 0 {74 val = val[:len(val)-1]75 }76 switch typ.Kind {77 case BufferString:78 s.strings[val] = true79 case BufferFilename:80 if len(val) < 3 || escapingFilename(val) {81 // This is not our file, probalby one of specialFiles.82 return83 }84 if val[len(val)-1] == 0 {85 val = val[:len(val)-1]86 }87 s.files[val] = true88 }89 }90 }91 })92}93type ArgCtx struct {94 Parent *[]Arg // GroupArg.Inner (for structs) or Call.Args containing this arg95 Fields []Field // Fields of the parent struct/syscall96 Base *PointerArg // pointer to the base of the heap object containing this arg97 Offset uint64 // offset of this arg from the base98 Stop bool // if set by the callback, subargs of this arg are not visited99}100func ForeachSubArg(arg Arg, f func(Arg, *ArgCtx)) {101 foreachArgImpl(arg, &ArgCtx{}, f)102}103func ForeachArg(c *Call, f func(Arg, *ArgCtx)) {104 ctx := &ArgCtx{}105 if c.Ret != nil {106 foreachArgImpl(c.Ret, ctx, f)107 }108 ctx.Parent = &c.Args109 ctx.Fields = c.Meta.Args110 for _, arg := range c.Args {111 foreachArgImpl(arg, ctx, f)112 }113}114func foreachArgImpl(arg Arg, ctx *ArgCtx, f func(Arg, *ArgCtx)) {115 ctx0 := *ctx116 defer func() { *ctx = ctx0 }()117 f(arg, ctx)118 if ctx.Stop {119 return120 }121 switch a := arg.(type) {122 case *GroupArg:123 if typ, ok := a.Type().(*StructType); ok {124 ctx.Parent = &a.Inner125 ctx.Fields = typ.Fields126 }127 var totalSize uint64128 for _, arg1 := range a.Inner {129 foreachArgImpl(arg1, ctx, f)130 size := arg1.Size()131 ctx.Offset += size132 totalSize += size133 }134 claimedSize := a.Size()135 varlen := a.Type().Varlen()136 if varlen && totalSize > claimedSize || !varlen && totalSize != claimedSize {137 panic(fmt.Sprintf("bad group arg size %v, should be <= %v for %#v type %#v",138 totalSize, claimedSize, a, a.Type()))139 }140 case *PointerArg:141 if a.Res != nil {142 ctx.Base = a143 ctx.Offset = 0144 foreachArgImpl(a.Res, ctx, f)145 }146 case *UnionArg:147 foreachArgImpl(a.Option, ctx, f)148 }149}150func RequiredFeatures(p *Prog) (bitmasks, csums bool) {151 for _, c := range p.Calls {152 ForeachArg(c, func(arg Arg, _ *ArgCtx) {153 if a, ok := arg.(*ConstArg); ok {154 if a.Type().BitfieldOffset() != 0 || a.Type().BitfieldLength() != 0 {155 bitmasks = true156 }157 }158 if _, ok := arg.Type().(*CsumType); ok {159 csums = true160 }161 })162 }163 return164}165type CallFlags int166const (167 CallExecuted CallFlags = 1 << iota // was started at all168 CallFinished // finished executing (rather than blocked forever)169 CallBlocked // finished but blocked during execution170)171type CallInfo struct {172 Flags CallFlags173 Errno int174 Signal []uint32175}176const (177 fallbackSignalErrno = iota178 fallbackSignalErrnoBlocked179 fallbackSignalCtor180 fallbackSignalFlags181 fallbackCallMask = 0x1fff182)183func (p *Prog) FallbackSignal(info []CallInfo) {184 resources := make(map[*ResultArg]*Call)185 for i, c := range p.Calls {186 inf := &info[i]187 if inf.Flags&CallExecuted == 0 {188 continue189 }190 id := c.Meta.ID191 typ := fallbackSignalErrno192 if inf.Flags&CallFinished != 0 && inf.Flags&CallBlocked != 0 {193 typ = fallbackSignalErrnoBlocked194 }195 inf.Signal = append(inf.Signal, encodeFallbackSignal(typ, id, inf.Errno))196 if c.Meta.Attrs.BreaksReturns {197 break198 }199 if inf.Errno != 0 {200 continue201 }202 ForeachArg(c, func(arg Arg, _ *ArgCtx) {203 if a, ok := arg.(*ResultArg); ok {204 resources[a] = c205 }206 })207 // Specifically look only at top-level arguments,208 // deeper arguments can produce too much false signal.209 flags := 0210 for _, arg := range c.Args {211 flags = extractArgSignal(arg, id, flags, inf, resources)212 }213 if flags != 0 {214 inf.Signal = append(inf.Signal,215 encodeFallbackSignal(fallbackSignalFlags, id, flags))216 }217 }218}219func extractArgSignal(arg Arg, callID, flags int, inf *CallInfo, resources map[*ResultArg]*Call) int {220 switch a := arg.(type) {221 case *ResultArg:222 flags <<= 1223 if a.Res != nil {224 ctor := resources[a.Res]225 if ctor != nil {226 inf.Signal = append(inf.Signal,227 encodeFallbackSignal(fallbackSignalCtor, callID, ctor.Meta.ID))228 }229 } else {230 if a.Val != a.Type().(*ResourceType).SpecialValues()[0] {231 flags |= 1232 }233 }234 case *ConstArg:235 const width = 3236 flags <<= width237 switch typ := a.Type().(type) {238 case *FlagsType:239 if typ.BitMask {240 for i, v := range typ.Vals {241 if a.Val&v != 0 {242 flags ^= 1 << (uint(i) % width)243 }244 }245 } else {246 for i, v := range typ.Vals {247 if a.Val == v {248 flags |= i % (1 << width)249 break250 }251 }252 }253 case *LenType:254 flags <<= 1255 if a.Val == 0 {256 flags |= 1257 }258 }259 case *PointerArg:260 flags <<= 1261 if a.IsSpecial() {262 flags |= 1263 }264 }265 return flags266}267func DecodeFallbackSignal(s uint32) (callID, errno int) {268 typ, id, aux := decodeFallbackSignal(s)269 switch typ {270 case fallbackSignalErrno, fallbackSignalErrnoBlocked:271 return id, aux272 case fallbackSignalCtor, fallbackSignalFlags:273 return id, 0274 default:275 panic(fmt.Sprintf("bad fallback signal type %v", typ))...

Full Screen

Full Screen

test.go

Source:test.go Github

copy

Full Screen

...64 if typ.Kind == prog.BufferString && len(typ.Values) == 1 {65 return // string const66 }67 case *prog.PtrType:68 if arg.(*prog.PointerArg).IsSpecial() {69 // TODO: we ought to mutate this, but we don't have code for this yet.70 return71 }72 return73 // Do not mutate the following types74 case *prog.ResourceType:75 return76 case *prog.FlagsType:77 return78 case *prog.LenType:79 return80 }81 typ := arg.Type()82 if typ == nil || typ.Dir() == prog.DirOut || !typ.Varlen() && typ.Size() == 0 {...

Full Screen

Full Screen

IsSpecial

Using AI Code Generation

copy

Full Screen

1import "fmt"2func main() {3 a = prog{1, "Go"}4 if a.IsSpecial() {5 fmt.Println("Special")6 } else {7 fmt.Println("Not Special")8 }9}10import "fmt"11type prog struct {12}13func (p prog) IsSpecial() bool {14}15func (p progList) IsSpecial() bool {16 return len(p) > 017}18func main() {19 p = prog{1, "Go"}20 pl = progList{prog{1, "Go"}, prog{2, "Java"}}21 if p.IsSpecial() {22 fmt.Println("Special")23 } else {24 fmt.Println("Not Special")25 }26 if pl.IsSpecial() {27 fmt.Println("Special")28 } else {29 fmt.Println("Not Special")30 }31}32import "fmt"33type prog struct {34}35func (p prog) IsSpecial() bool {36}37func (p progList) IsSpecial() bool {38 return len(p) > 039}40func main() {41 p = prog{1, "Go"}42 pl = progList{prog{1, "Go"}, prog{2, "Java"}}43 if p.IsSpecial() {44 fmt.Println("Special")45 } else {46 fmt.Println("Not Special")47 }48 if pl.IsSpecial() {49 fmt.Println("Special")50 } else {51 fmt.Println("Not Special")52 }53}

Full Screen

Full Screen

IsSpecial

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Printf("Is %d special? %t4", i, i.IsSpecial())5}6import (7func main() {8 fmt.Printf("Is %d special? %t9", i, i.IsSpecial())10}11import (12func main() {13 fmt.Printf("Is %d special? %t14", i, i.IsSpecial())15}16The prog package can be imported in the main package by using the import statement. The prog package can be

Full Screen

Full Screen

IsSpecial

Using AI Code Generation

copy

Full Screen

1import "fmt"2import "prog"3func main() {4 fmt.Println(prog.IsSpecial(5))5}6func IsSpecial(n int) bool {7 if n == 2 || n == 3 || n == 5 || n == 7 {8 }9}10import "fmt"11import "prog"12func main() {13 fmt.Println(prog.IsSpecial(5))14}15func isSpecial(n int) bool {16 if n == 2 || n == 3 || n == 5 || n == 7 {17 }18}19import "fmt"20import "prog"21func main() {22 fmt.Println(prog.IsSpecial(5))23}

Full Screen

Full Screen

IsSpecial

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println("IsSpecial(5) = ", prog.IsSpecial(5))4 fmt.Println("IsSpecial(7) = ", prog.IsSpecial(7))5}6IsSpecial(5) = false7IsSpecial(7) = true

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Syzkaller automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful