From 6839de7050c6949fee1d3a5fc3e53cf363a5a172 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Thu, 22 Nov 2018 07:40:50 +0100 Subject: pkg/report: fix corrupted stack trace checking We started detecting all kernel reboots as corrupted, because we considered that after any "Allocated" line a stack trace should follow. Kernel boot output now contains: ima: Allocated hash algorithm: sha256 and there is no stack trace after that. 1. Refine stack trace regexps (we actually want to look for "Allocated by task PID:" lines). 2. Don't check stacks if report format says that it does not contain stacks. --- pkg/report/linux.go | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'pkg/report/linux.go') diff --git a/pkg/report/linux.go b/pkg/report/linux.go index cec2b4e69..c397919bc 100644 --- a/pkg/report/linux.go +++ b/pkg/report/linux.go @@ -464,17 +464,20 @@ func (ctx *linux) extractFiles(report []byte) []string { } func (ctx *linux) isCorrupted(title string, report []byte, format oopsFormat) (bool, string) { - // Check if the report contains stack trace. - if !format.noStackTrace && !bytes.Contains(report, []byte("Call Trace")) && - !bytes.Contains(report, []byte("backtrace")) { - return true, "no stack trace in report" - } // Check for common title corruptions. for _, re := range linuxCorruptedTitles { if re.MatchString(title) { return true, "title matches corrupted regexp" } } + // Check if the report contains stack trace. + if !format.noStackTrace && !bytes.Contains(report, []byte("Call Trace")) && + !bytes.Contains(report, []byte("backtrace")) { + return true, "no stack trace in report" + } + if format.noStackTrace { + return false, "" + } // When a report contains 'Call Trace', 'backtrace', 'Allocated' or 'Freed' keywords, // it must also contain at least a single stack frame after each of them. for _, key := range linuxStackKeywords { @@ -621,8 +624,10 @@ var linuxCorruptedTitles = []*regexp.Regexp{ var linuxStackKeywords = []*regexp.Regexp{ regexp.MustCompile(`Call Trace`), - regexp.MustCompile(`Allocated`), - regexp.MustCompile(`Freed`), + regexp.MustCompile(`Allocated:`), + regexp.MustCompile(`Allocated by task [0-9]+:`), + regexp.MustCompile(`Freed:`), + regexp.MustCompile(`Freed by task [0-9]+:`), // Match 'backtrace:', but exclude 'stack backtrace:' regexp.MustCompile(`[^k] backtrace:`), } -- cgit mrf-deployment