aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/report/linux.go
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2023-06-15 13:49:34 +0200
committerAleksandr Nogikh <nogikh@google.com>2023-07-05 11:29:44 +0000
commitd9b02a53a6f8a9f6af36ffdf2ac399e3376de807 (patch)
tree1df60eda630701af92a38fcd83617f40bef32e6e /pkg/report/linux.go
parent1c8e48305a43b3ebe84d2c046ba1da31d70284a8 (diff)
pkg/report: extract more report types for Linux
Amend oops and oopsFormat to contain report type.
Diffstat (limited to 'pkg/report/linux.go')
-rw-r--r--pkg/report/linux.go169
1 files changed, 120 insertions, 49 deletions
diff --git a/pkg/report/linux.go b/pkg/report/linux.go
index 02dbc3e61..a13a326bd 100644
--- a/pkg/report/linux.go
+++ b/pkg/report/linux.go
@@ -176,6 +176,7 @@ func (ctx *linux) Parse(output []byte) *Report {
}
rep.reportPrefixLen = len(rep.Report)
rep.Report = append(rep.Report, report...)
+ setReportType(rep, oops, format)
if !rep.Corrupted {
rep.Corrupted, rep.CorruptedReason = ctx.isCorrupted(title, report, format)
}
@@ -1323,6 +1324,7 @@ var linuxOopses = append([]*oops{
// These frames are present in KASAN_HW_TAGS reports.
skip: []string{"kernel_fault", "tag_check", "mem_abort", "^el1_", "^el1h_"},
},
+ reportType: KASAN,
},
{
title: compile("BUG: KASAN:"),
@@ -1337,15 +1339,18 @@ var linuxOopses = append([]*oops{
},
skip: []string{"slab_", "kfree", "vunmap", "vfree"},
},
+ reportType: KASAN,
},
{
- title: compile("BUG: KASAN: ([a-z\\-]+) on address(?:.*\\n)+?.*(Read|Write) of size ([0-9]+)"),
- fmt: "KASAN: %[1]v %[2]v",
+ title: compile("BUG: KASAN: ([a-z\\-]+) on address(?:.*\\n)+?.*(Read|Write) of size ([0-9]+)"),
+ fmt: "KASAN: %[1]v %[2]v",
+ reportType: KASAN,
},
{
- title: compile("BUG: KASAN: (.*)"),
- fmt: "KASAN: %[1]v",
- corrupted: true,
+ title: compile("BUG: KASAN: (.*)"),
+ fmt: "KASAN: %[1]v",
+ corrupted: true,
+ reportType: KASAN,
},
{
title: compile("BUG: KMSAN: kernel-usb-infoleak"),
@@ -1381,6 +1386,13 @@ var linuxOopses = append([]*oops{
noStackTrace: true,
},
{
+ title: compile("BUG: KCSAN: data-race"),
+ report: compile("BUG: KCSAN: (.*)"),
+ fmt: "KCSAN: %[1]v",
+ noStackTrace: true,
+ reportType: DataRace,
+ },
+ {
title: compile("BUG: KCSAN:"),
report: compile("BUG: KCSAN: (.*)"),
fmt: "KCSAN: %[1]v",
@@ -1473,6 +1485,7 @@ var linuxOopses = append([]*oops{
},
skip: []string{"spin_", "_lock", "_unlock"},
},
+ reportType: LockdepBug,
},
{
title: compile("BUG: soft lockup"),
@@ -1486,11 +1499,13 @@ var linuxOopses = append([]*oops{
},
extractor: linuxStallFrameExtractor,
},
+ reportType: Hang,
},
{
- title: compile("BUG: .*still has locks held!"),
- report: compile("BUG: .*still has locks held!(?:.*\\n)+?.*{{PC}} +{{FUNC}}"),
- fmt: "BUG: still has locks held in %[1]v",
+ title: compile("BUG: .*still has locks held!"),
+ report: compile("BUG: .*still has locks held!(?:.*\\n)+?.*{{PC}} +{{FUNC}}"),
+ fmt: "BUG: still has locks held in %[1]v",
+ reportType: LockdepBug,
},
{
title: compile("BUG: scheduling while atomic"),
@@ -1502,6 +1517,7 @@ var linuxOopses = append([]*oops{
},
skip: []string{"schedule"},
},
+ reportType: AtomicSleep,
},
{
title: compile("BUG: lock held when returning to user space"),
@@ -1519,11 +1535,13 @@ var linuxOopses = append([]*oops{
parseStackTrace,
},
},
+ reportType: LockdepBug,
},
{
- title: compile("BUG: held lock freed!"),
- report: compile("BUG: held lock freed!(?:.*\\n)+?.*{{PC}} +{{FUNC}}"),
- fmt: "BUG: held lock freed in %[1]v",
+ title: compile("BUG: held lock freed!"),
+ report: compile("BUG: held lock freed!(?:.*\\n)+?.*{{PC}} +{{FUNC}}"),
+ fmt: "BUG: held lock freed in %[1]v",
+ reportType: LockdepBug,
},
{
title: compile("BUG: Bad rss-counter state"),
@@ -1571,6 +1589,7 @@ var linuxOopses = append([]*oops{
parseStackTrace,
},
},
+ reportType: AtomicSleep,
},
{
title: compile("BUG: using ([a-z_]+)\\(\\) in preemptible"),
@@ -1593,7 +1612,7 @@ var linuxOopses = append([]*oops{
},
{
title: compile("BUG: memory leak"),
- fmt: memoryLeakPrefix + "%[1]v",
+ fmt: "memory leak in %[1]v",
stack: &stackFmt{
parts: []*regexp.Regexp{
compile("backtrace:"),
@@ -1603,6 +1622,7 @@ var linuxOopses = append([]*oops{
"idr_get", "list_lru_init", "kasprintf", "kvasprintf",
"pcpu_create", "strdup", "strndup", "memdup"},
},
+ reportType: MemoryLeak,
},
{
title: compile("BUG: .*stack guard page was hit at"),
@@ -1616,6 +1636,7 @@ var linuxOopses = append([]*oops{
},
extractor: linuxStallFrameExtractor,
},
+ reportType: unspecifiedType, // This is a printk(), not a BUG_ON().
},
{
title: compile("BUG: Invalid wait context"),
@@ -1629,6 +1650,7 @@ var linuxOopses = append([]*oops{
},
skip: []string{"lock_sock", "release_sock"},
},
+ reportType: LockdepBug,
},
{
title: compile(`BUG:[[:space:]]*(?:\n|$)`),
@@ -1647,6 +1669,7 @@ var linuxOopses = append([]*oops{
// pkg/host output in debug mode.
compile("BUG: no syscalls can create resource"),
},
+ UnknownType,
},
{
[]byte("WARNING:"),
@@ -1680,25 +1703,29 @@ var linuxOopses = append([]*oops{
stack: warningStackFmt("refcount", "kobject_"),
},
{
- title: compile("WARNING: .*kernel/locking/lockdep\\.c.*lock_"),
- fmt: "WARNING: locking bug in %[1]v",
- stack: warningStackFmt("lock_sock", "release_sock"),
+ title: compile("WARNING: .*kernel/locking/lockdep\\.c.*lock_"),
+ fmt: "WARNING: locking bug in %[1]v",
+ stack: warningStackFmt("lock_sock", "release_sock"),
+ reportType: LockdepBug,
},
{
- title: compile("WARNING: .*still has locks held!"),
- report: compile("WARNING: .*still has locks held!(?:.*\\n)+?.*at: {{FUNC}}"),
- fmt: "WARNING: still has locks held in %[1]v",
+ title: compile("WARNING: .*still has locks held!"),
+ report: compile("WARNING: .*still has locks held!(?:.*\\n)+?.*at: {{FUNC}}"),
+ fmt: "WARNING: still has locks held in %[1]v",
+ reportType: LockdepBug,
},
{
- title: compile("WARNING: Nested lock was not taken"),
- fmt: "WARNING: nested lock was not taken in %[1]v",
- stack: warningStackFmt(),
+ title: compile("WARNING: Nested lock was not taken"),
+ fmt: "WARNING: nested lock was not taken in %[1]v",
+ stack: warningStackFmt(),
+ reportType: LockdepBug,
},
{
title: compile("WARNING: lock held when returning to user space"),
report: compile("WARNING: lock held when returning to user space(?:.*\\n)+?.*leaving the kernel with locks still held(?:.*\\n)+?.*at: (?:{{PC}} +)?{{FUNC}}"),
fmt: "WARNING: lock held when returning to user space in %[1]v",
noStackTrace: true,
+ reportType: LockdepBug,
},
{
title: compile("WARNING: .*mm/.*\\.c.* k?.?malloc"),
@@ -1736,11 +1763,13 @@ var linuxOopses = append([]*oops{
skip: []string{"process_one_work", "flush_workqueue",
"drain_workqueue", "destroy_workqueue"},
},
+ reportType: LockdepBug,
},
{
- title: compile("WARNING: possible irq lock inversion dependency detected"),
- report: compile("WARNING: possible irq lock inversion dependency detected(?:.*\\n)+?.*just changed the state of lock(?:.*\\n)+?.*at: (?:{{PC}} +)?{{FUNC}}"),
- fmt: "possible deadlock in %[1]v",
+ title: compile("WARNING: possible irq lock inversion dependency detected"),
+ report: compile("WARNING: possible irq lock inversion dependency detected(?:.*\\n)+?.*just changed the state of lock(?:.*\\n)+?.*at: (?:{{PC}} +)?{{FUNC}}"),
+ fmt: "possible deadlock in %[1]v",
+ reportType: LockdepBug,
},
{
title: compile("WARNING: .*-safe -> .*-unsafe lock order detected"),
@@ -1751,11 +1780,13 @@ var linuxOopses = append([]*oops{
parseStackTrace,
},
},
+ reportType: LockdepBug,
},
{
- title: compile("WARNING: possible recursive locking detected"),
- report: compile("WARNING: possible recursive locking detected(?:.*\\n)+?.*is trying to acquire lock(?:.*\\n)+?.*at: (?:{{PC}} +)?{{FUNC}}"),
- fmt: "possible deadlock in %[1]v",
+ title: compile("WARNING: possible recursive locking detected"),
+ report: compile("WARNING: possible recursive locking detected(?:.*\\n)+?.*is trying to acquire lock(?:.*\\n)+?.*at: (?:{{PC}} +)?{{FUNC}}"),
+ fmt: "possible deadlock in %[1]v",
+ reportType: LockdepBug,
},
{
title: compile("WARNING: inconsistent lock state"),
@@ -1767,6 +1798,7 @@ var linuxOopses = append([]*oops{
parseStackTrace,
},
},
+ reportType: LockdepBug,
},
{
title: compile("WARNING: suspicious RCU usage"),
@@ -1779,16 +1811,19 @@ var linuxOopses = append([]*oops{
},
skip: []string{"rcu", "kmem", "slab"},
},
+ reportType: LockdepBug,
},
{
title: compile("WARNING: kernel stack regs at [0-9a-f]+ in [^ ]* has bad '([^']+)' value"),
fmt: "WARNING: kernel stack regs has bad '%[1]v' value",
noStackTrace: true,
+ reportType: unspecifiedType, // This is printk().
},
{
title: compile("WARNING: kernel stack frame pointer at [0-9a-f]+ in [^ ]* has bad value"),
fmt: "WARNING: kernel stack frame pointer has bad value",
noStackTrace: true,
+ reportType: unspecifiedType, // This is printk().
},
{
title: compile("WARNING: bad unlock balance detected!"),
@@ -1800,26 +1835,31 @@ var linuxOopses = append([]*oops{
parseStackTrace,
},
},
+ reportType: LockdepBug,
},
{
- title: compile("WARNING: held lock freed!"),
- report: compile("WARNING: held lock freed!(?:.*\\n)+?.*at:(?: {{PC}})? +{{FUNC}}"),
- fmt: "WARNING: held lock freed in %[1]v",
+ title: compile("WARNING: held lock freed!"),
+ report: compile("WARNING: held lock freed!(?:.*\\n)+?.*at:(?: {{PC}})? +{{FUNC}}"),
+ fmt: "WARNING: held lock freed in %[1]v",
+ reportType: LockdepBug,
},
{
title: compile("WARNING: kernel stack regs .* has bad 'bp' value"),
fmt: "WARNING: kernel stack regs has bad value",
noStackTrace: true,
+ reportType: unspecifiedType, // This is printk().
},
{
title: compile("WARNING: kernel stack frame pointer .* has bad value"),
fmt: "WARNING: kernel stack regs has bad value",
noStackTrace: true,
+ reportType: unspecifiedType, // This is printk().
},
{
- title: compile(`WARNING:[[:space:]]*(?:\n|$)`),
- fmt: "WARNING: corrupted",
- corrupted: true,
+ title: compile(`WARNING:[[:space:]]*(?:\n|$)`),
+ fmt: "WARNING: corrupted",
+ corrupted: true,
+ reportType: unspecifiedType, // This is printk().
},
},
[]*regexp.Regexp{
@@ -1830,34 +1870,40 @@ var linuxOopses = append([]*oops{
compile("WARNING: Unprivileged eBPF is enabled with eIBRS"),
compile(`WARNING: fbcon: Driver '(.*)' missed to adjust virtual screen size (\((?:\d+)x(?:\d+) vs\. (?:\d+)x(?:\d+)\))`),
},
+ Warning,
},
{
[]byte("INFO:"),
[]oopsFormat{
{
- title: compile("INFO: possible circular locking dependency detected"),
- report: compile("INFO: possible circular locking dependency detected \\](?:.*\\n)+?.*is trying to acquire lock(?:.*\\n)+?.*at: {{PC}} +{{FUNC}}"),
- fmt: "possible deadlock in %[1]v",
+ title: compile("INFO: possible circular locking dependency detected"),
+ report: compile("INFO: possible circular locking dependency detected \\](?:.*\\n)+?.*is trying to acquire lock(?:.*\\n)+?.*at: {{PC}} +{{FUNC}}"),
+ fmt: "possible deadlock in %[1]v",
+ reportType: LockdepBug,
},
{
- title: compile("INFO: possible irq lock inversion dependency detected"),
- report: compile("INFO: possible irq lock inversion dependency detected \\](?:.*\\n)+?.*just changed the state of lock(?:.*\\n)+?.*at: {{PC}} +{{FUNC}}"),
- fmt: "possible deadlock in %[1]v",
+ title: compile("INFO: possible irq lock inversion dependency detected"),
+ report: compile("INFO: possible irq lock inversion dependency detected \\](?:.*\\n)+?.*just changed the state of lock(?:.*\\n)+?.*at: {{PC}} +{{FUNC}}"),
+ fmt: "possible deadlock in %[1]v",
+ reportType: LockdepBug,
},
{
- title: compile("INFO: SOFTIRQ-safe -> SOFTIRQ-unsafe lock order detected"),
- report: compile("INFO: SOFTIRQ-safe -> SOFTIRQ-unsafe lock order detected \\](?:.*\\n)+?.*is trying to acquire(?:.*\\n)+?.*at: {{PC}} +{{FUNC}}"),
- fmt: "possible deadlock in %[1]v",
+ title: compile("INFO: SOFTIRQ-safe -> SOFTIRQ-unsafe lock order detected"),
+ report: compile("INFO: SOFTIRQ-safe -> SOFTIRQ-unsafe lock order detected \\](?:.*\\n)+?.*is trying to acquire(?:.*\\n)+?.*at: {{PC}} +{{FUNC}}"),
+ fmt: "possible deadlock in %[1]v",
+ reportType: LockdepBug,
},
{
- title: compile("INFO: possible recursive locking detected"),
- report: compile("INFO: possible recursive locking detected \\](?:.*\\n)+?.*is trying to acquire lock(?:.*\\n)+?.*at: {{PC}} +{{FUNC}}"),
- fmt: "possible deadlock in %[1]v",
+ title: compile("INFO: possible recursive locking detected"),
+ report: compile("INFO: possible recursive locking detected \\](?:.*\\n)+?.*is trying to acquire lock(?:.*\\n)+?.*at: {{PC}} +{{FUNC}}"),
+ fmt: "possible deadlock in %[1]v",
+ reportType: LockdepBug,
},
{
- title: compile("INFO: inconsistent lock state"),
- report: compile("INFO: inconsistent lock state \\](?:.*\\n)+?.*takes(?:.*\\n)+?.*at: {{PC}} +{{FUNC}}"),
- fmt: "inconsistent lock state in %[1]v",
+ title: compile("INFO: inconsistent lock state"),
+ report: compile("INFO: inconsistent lock state \\](?:.*\\n)+?.*takes(?:.*\\n)+?.*at: {{PC}} +{{FUNC}}"),
+ fmt: "inconsistent lock state in %[1]v",
+ reportType: LockdepBug,
},
{
title: compile("INFO: rcu_(?:preempt|sched|bh) (?:self-)?detected(?: expedited)? stall"),
@@ -1876,6 +1922,7 @@ var linuxOopses = append([]*oops{
skip: []string{"apic_timer_interrupt", "rcu"},
extractor: linuxStallFrameExtractor,
},
+ reportType: Hang,
},
{
title: compile("INFO: trying to register non-static key"),
@@ -1911,6 +1958,7 @@ var linuxOopses = append([]*oops{
},
extractor: linuxHangTaskFrameExtractor,
},
+ reportType: Hang,
},
{
title: compile("INFO: task .* can't die for more than .* seconds"),
@@ -1923,6 +1971,7 @@ var linuxOopses = append([]*oops{
},
skip: []string{"schedule"},
},
+ reportType: Hang,
},
{
// This gets captured for corrupted old-style KASAN reports.
@@ -1948,6 +1997,7 @@ var linuxOopses = append([]*oops{
compile("CAM_INFO:"), // Android prints this.
compile("rmt_storage:INFO:"), // Android prints this.
},
+ UnknownType,
},
{
[]byte("Unable to handle kernel"),
@@ -1966,6 +2016,7 @@ var linuxOopses = append([]*oops{
},
},
[]*regexp.Regexp{},
+ UnknownType,
},
{
[]byte("general protection fault"),
@@ -1986,6 +2037,7 @@ var linuxOopses = append([]*oops{
[]*regexp.Regexp{
compile(`general protection fault .* error:\d+ in `),
},
+ UnknownType,
},
{
[]byte("stack segment: "),
@@ -2003,6 +2055,7 @@ var linuxOopses = append([]*oops{
},
},
[]*regexp.Regexp{},
+ UnknownType,
},
{
[]byte("Kernel panic"),
@@ -2088,6 +2141,7 @@ var linuxOopses = append([]*oops{
},
},
[]*regexp.Regexp{},
+ UnknownType,
},
{
[]byte("PANIC: double fault"),
@@ -2103,6 +2157,7 @@ var linuxOopses = append([]*oops{
},
},
[]*regexp.Regexp{},
+ UnknownType,
},
{
[]byte("kernel BUG"),
@@ -2144,6 +2199,7 @@ var linuxOopses = append([]*oops{
},
},
[]*regexp.Regexp{},
+ Bug,
},
{
[]byte("Kernel BUG"),
@@ -2154,6 +2210,7 @@ var linuxOopses = append([]*oops{
},
},
[]*regexp.Regexp{},
+ Bug,
},
{
[]byte("BUG kmalloc-"),
@@ -2164,6 +2221,7 @@ var linuxOopses = append([]*oops{
},
},
[]*regexp.Regexp{},
+ UnknownType,
},
{
[]byte("divide error:"),
@@ -2179,6 +2237,7 @@ var linuxOopses = append([]*oops{
},
},
[]*regexp.Regexp{},
+ UnknownType,
},
{
// A misspelling of the above introduced in 9d06c4027f21 ("x86/entry: Convert Divide Error to IDTENTRY").
@@ -2195,6 +2254,7 @@ var linuxOopses = append([]*oops{
},
},
[]*regexp.Regexp{},
+ UnknownType,
},
{
[]byte("invalid opcode:"),
@@ -2210,6 +2270,7 @@ var linuxOopses = append([]*oops{
},
},
[]*regexp.Regexp{},
+ UnknownType,
},
{
[]byte("UBSAN:"),
@@ -2252,14 +2313,16 @@ var linuxOopses = append([]*oops{
},
},
[]*regexp.Regexp{},
+ UBSAN,
},
{
[]byte("Booting the kernel."),
[]oopsFormat{
{
title: compile("Booting the kernel."),
- fmt: unexpectedKernelReboot,
+ fmt: "unexpected kernel reboot",
noStackTrace: true,
+ reportType: UnexpectedReboot,
},
},
[]*regexp.Regexp{
@@ -2268,6 +2331,7 @@ var linuxOopses = append([]*oops{
// as an invalid mount option and we detect false reboot.
compile("Parsing ELF|Decompressing Linux"),
},
+ UnknownType,
},
{
[]byte("unregister_netdevice: waiting for"),
@@ -2279,6 +2343,7 @@ var linuxOopses = append([]*oops{
},
},
[]*regexp.Regexp{},
+ UnknownType,
},
{
// Custom vfs error printed by older versions of the kernel, see #3621.
@@ -2291,6 +2356,7 @@ var linuxOopses = append([]*oops{
},
},
[]*regexp.Regexp{},
+ UnknownType,
},
{
// Custom vfs error printed by older versions of the kernel, see #3621.
@@ -2303,6 +2369,7 @@ var linuxOopses = append([]*oops{
},
},
[]*regexp.Regexp{},
+ UnknownType,
},
{
[]byte("Internal error:"),
@@ -2324,6 +2391,7 @@ var linuxOopses = append([]*oops{
},
},
[]*regexp.Regexp{},
+ UnknownType,
},
{
[]byte("Unhandled fault:"),
@@ -2344,6 +2412,7 @@ var linuxOopses = append([]*oops{
},
},
[]*regexp.Regexp{},
+ UnknownType,
},
{
[]byte("Alignment trap:"),
@@ -2361,6 +2430,7 @@ var linuxOopses = append([]*oops{
},
},
[]*regexp.Regexp{},
+ UnknownType,
},
{
[]byte("trusty: panic"),
@@ -2384,5 +2454,6 @@ var linuxOopses = append([]*oops{
},
},
[]*regexp.Regexp{},
+ UnknownType,
},
}, commonOopses...)