diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2022-01-12 15:50:08 +0100 |
|---|---|---|
| committer | Aleksandr Nogikh <wp32pw@gmail.com> | 2022-01-13 17:03:25 +0100 |
| commit | 7c9ea12ca3d0db0eeb2b448844ffbf80ba599f90 (patch) | |
| tree | 2a8769a10625493c1b42ec8a65a012f3446f913c /tools/syz-check | |
| parent | a252f56d36e0c85a0106b341188fcb19e87fda15 (diff) | |
tools/syz-check: don't check netlink policies as structs
They are not really structs in the kernel even if we describe them as structs.
Diffstat (limited to 'tools/syz-check')
| -rw-r--r-- | tools/syz-check/check.go | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/tools/syz-check/check.go b/tools/syz-check/check.go index 63606d23a..2634f27f7 100644 --- a/tools/syz-check/check.go +++ b/tools/syz-check/check.go @@ -213,6 +213,9 @@ func checkImpl(structs map[string]*dwarf.StructType, structTypes []prog.Type, if astStruct == nil { continue } + if _, ok := isNetlinkPolicy(typ); ok { + continue // netlink policies are not structs even if we describe them as structs + } // In some cases we split a single struct into multiple ones // (more precise description), so try to match our foo$bar with kernel foo. kernelStruct := structs[name] @@ -409,14 +412,8 @@ func checkNetlinkStruct(locs map[string]*ast.Struct, symbols map[string][]symbol if astStruct == nil { return nil, nil } - var fields []prog.Field - switch t := typ.(type) { - case *prog.StructType: - fields = t.Fields - case *prog.UnionType: - fields = t.Fields - } - if !isNetlinkPolicy(fields) { + fields, ok := isNetlinkPolicy(typ) + if !ok { return nil, nil } // In some cases we split a single policy into multiple ones (more precise description), @@ -513,7 +510,16 @@ func checkMissingAttrs(checkedAttrs map[string]*checkAttr) []Warn { return warnings } -func isNetlinkPolicy(fields []prog.Field) bool { +func isNetlinkPolicy(typ prog.Type) ([]prog.Field, bool) { + var fields []prog.Field + switch t := typ.(type) { + case *prog.StructType: + fields = t.Fields + case *prog.UnionType: + fields = t.Fields + default: + return nil, false + } haveAttr := false for _, fld := range fields { field := fld.Type @@ -527,19 +533,12 @@ func isNetlinkPolicy(fields []prog.Field) bool { if arr, ok := field.(*prog.ArrayType); ok { field = arr.Elem } - if field1, ok := field.(*prog.StructType); ok { - if isNetlinkPolicy(field1.Fields) { - continue - } - } - if field1, ok := field.(*prog.UnionType); ok { - if isNetlinkPolicy(field1.Fields) { - continue - } + if _, ok := isNetlinkPolicy(field); ok { + continue } - return false + return nil, false } - return haveAttr + return fields, haveAttr } const ( |
