diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2022-01-11 20:09:20 +0100 |
|---|---|---|
| committer | Aleksandr Nogikh <wp32pw@gmail.com> | 2022-01-13 17:03:25 +0100 |
| commit | 4b0229115958fea4fb48302ee17980f6a0bb859d (patch) | |
| tree | 6eb9be268b3d7da3b94750a8f85e92b662f0dddd /tools/syz-check | |
| parent | 24c8419d0db44a0dec71116360d40bd9c82e92b3 (diff) | |
tools/syz-check: use $ as struct variant suffix delimiter
We already use this $ convention for syscall variant names.
Use the same convention for struct.
Currently syz-check supports '_' for structs, but it's
inconsistent with syscalls and leads to ambiguity.
If we enable the same matching for all structs (not just netlink),
then '_' creates lots of false matches. E.g. bpf_link_get_next_id_args
is matches with internal bpf_link struct.
Diffstat (limited to 'tools/syz-check')
| -rw-r--r-- | tools/syz-check/check.go | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/tools/syz-check/check.go b/tools/syz-check/check.go index 41c9c6b10..6f59a1fa6 100644 --- a/tools/syz-check/check.go +++ b/tools/syz-check/check.go @@ -206,7 +206,13 @@ func checkImpl(structs map[string]*dwarf.StructType, structTypes []prog.Type, if astStruct == nil { continue } - warns, err := checkStruct(typ, astStruct, structs[name]) + // 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] + if delim := strings.LastIndexByte(name, '$'); kernelStruct == nil && delim != -1 { + kernelStruct = structs[name[:delim]] + } + warns, err := checkStruct(typ, astStruct, kernelStruct) if err != nil { return nil, err } @@ -406,21 +412,12 @@ func checkNetlinkStruct(locs map[string]*ast.Struct, symbols map[string][]symbol if !isNetlinkPolicy(fields) { return nil, nil } - kernelName := name - var ss []symbolizer.Symbol - // In some cases we split a single policy into multiple ones - // (more precise description), so try to match our foo_bar_baz - // with kernel foo_bar and foo as well. - for kernelName != "" { + // In some cases we split a single policy into multiple ones (more precise description), + // so try to match our foo$bar with with kernel foo as well. + kernelName, ss := name, symbols[name] + if delim := strings.LastIndexByte(name, '$'); len(ss) == 0 && delim != -1 { + kernelName = name[:delim] ss = symbols[kernelName] - if len(ss) != 0 { - break - } - underscore := strings.LastIndexByte(kernelName, '_') - if underscore == -1 { - break - } - kernelName = kernelName[:underscore] } if len(ss) == 0 { return []Warn{{pos: astStruct.Pos, typ: WarnNoNetlinkPolicy, msg: name}}, nil |
