mirror of
https://github.com/reactos/syzkaller.git
synced 2025-02-26 06:35:31 +00:00

1. Replace stacktraceRe with custom code which is more flexible. stacktraceRe stumbled on any unrelated lines and could not properly parse truncated stacks. 2. Match report regexp earlier. If we match simler title regexp, but don't match report regexp or fail to parse stack trace, the report is corrupted. This eliminates lots of duplicate corrupted oops entries, which were there only because we had complex regexp's in titles. 3. Ignore low-level frames during stack parsing. E.g. we never want to report a GPF in lock_acquire or memcpy (somewhat similar to what we do for guilty files). 4. Add a bunch of specialized formats for WARNINGs. There is number of generic debugging facilities (like ODEBUG, debug usercopy, kobject, refcount_t, etc), and the bug is never in these facilities, it's in the caller instead. 5. Improve some other oops formats. 6. Add a bunch of additional tests. This resolves most of TODOs in tests. Fixes #515
110 lines
2.5 KiB
Go
110 lines
2.5 KiB
Go
// Copyright 2017 syzkaller project authors. All rights reserved.
|
|
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
|
|
|
|
package report
|
|
|
|
import (
|
|
"bytes"
|
|
"regexp"
|
|
|
|
"github.com/google/syzkaller/pkg/symbolizer"
|
|
)
|
|
|
|
type freebsd struct {
|
|
kernelSrc string
|
|
kernelObj string
|
|
symbols map[string][]symbolizer.Symbol
|
|
ignores []*regexp.Regexp
|
|
}
|
|
|
|
func ctorFreebsd(kernelSrc, kernelObj string, symbols map[string][]symbolizer.Symbol,
|
|
ignores []*regexp.Regexp) (Reporter, error) {
|
|
ctx := &freebsd{
|
|
kernelSrc: kernelSrc,
|
|
kernelObj: kernelObj,
|
|
symbols: symbols,
|
|
ignores: ignores,
|
|
}
|
|
return ctx, nil
|
|
}
|
|
|
|
func (ctx *freebsd) ContainsCrash(output []byte) bool {
|
|
return containsCrash(output, freebsdOopses, ctx.ignores)
|
|
}
|
|
|
|
func (ctx *freebsd) Parse(output []byte) *Report {
|
|
rep := &Report{
|
|
Output: output,
|
|
}
|
|
var oops *oops
|
|
for pos := 0; pos < len(output); {
|
|
next := bytes.IndexByte(output[pos:], '\n')
|
|
if next != -1 {
|
|
next += pos
|
|
} else {
|
|
next = len(output)
|
|
}
|
|
for _, oops1 := range freebsdOopses {
|
|
match := matchOops(output[pos:next], oops1, ctx.ignores)
|
|
if match == -1 {
|
|
continue
|
|
}
|
|
if oops == nil {
|
|
oops = oops1
|
|
rep.StartPos = pos
|
|
rep.Title = string(output[pos+match : next])
|
|
}
|
|
rep.EndPos = next
|
|
}
|
|
// Console output is indistinguishable from fuzzer output,
|
|
// so we just collect everything after the oops.
|
|
if oops != nil {
|
|
lineEnd := next
|
|
if lineEnd != 0 && output[lineEnd-1] == '\r' {
|
|
lineEnd--
|
|
}
|
|
rep.Report = append(rep.Report, output[pos:lineEnd]...)
|
|
rep.Report = append(rep.Report, '\n')
|
|
}
|
|
pos = next + 1
|
|
}
|
|
if oops == nil {
|
|
return nil
|
|
}
|
|
rep.Title, rep.Corrupted, _ = extractDescription(output[rep.StartPos:], oops, freebsdStackParams)
|
|
return rep
|
|
}
|
|
|
|
func (ctx *freebsd) Symbolize(rep *Report) error {
|
|
return nil
|
|
}
|
|
|
|
var freebsdStackParams = &stackParams{}
|
|
|
|
var freebsdOopses = []*oops{
|
|
&oops{
|
|
[]byte("Fatal trap"),
|
|
[]oopsFormat{
|
|
{
|
|
title: compile("Fatal trap (.+?)\\r?\\n(?:.*\\n)+?" +
|
|
"KDB: stack backtrace:\\r?\\n" +
|
|
"(?:#[0-9]+ {{ADDR}} at (?:kdb_backtrace|vpanic|panic|trap_fatal|" +
|
|
"trap_pfault|trap|calltrap|m_copydata|__rw_wlock_hard)" +
|
|
"\\+{{ADDR}}\\r?\\n)*#[0-9]+ {{ADDR}} at {{FUNC}}{{ADDR}}"),
|
|
fmt: "Fatal trap %[1]v in %[2]v",
|
|
},
|
|
},
|
|
[]*regexp.Regexp{},
|
|
},
|
|
&oops{
|
|
[]byte("panic:"),
|
|
[]oopsFormat{
|
|
{
|
|
title: compile("panic: ffs_write: type {{ADDR}} [0-9]+ \\([0-9]+,[0-9]+\\)"),
|
|
fmt: "panic: ffs_write: type ADDR X (Y,Z)",
|
|
},
|
|
},
|
|
[]*regexp.Regexp{},
|
|
},
|
|
}
|