From c8b87c9cf704f1e3a11fc0ca7cf610631265b3c1 Mon Sep 17 00:00:00 2001 From: Andrey Konovalov Date: Wed, 22 Nov 2017 13:37:30 +0100 Subject: pkg/report: fix corrupted KASAN reports detection KASAN report might not have Allocated or Freed stack traces at all. --- pkg/report/linux.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'pkg/report/linux.go') diff --git a/pkg/report/linux.go b/pkg/report/linux.go index a1489a553..dde5d29aa 100644 --- a/pkg/report/linux.go +++ b/pkg/report/linux.go @@ -348,15 +348,16 @@ func (ctx *linux) isCorrupted(title string, report []byte) bool { } } if strings.HasPrefix(title, "KASAN") { - // For KASAN reports lets use 'Allocated' and 'Freed' as signals. - if !bytes.Contains(report, []byte("Allocated")) { + // KASAN reports must contain 'Call Trace' after 'KASAN:' header. + match := bytes.Index(report, []byte("KASAN:")) + if match == -1 { return true } - if !bytes.Contains(report, []byte("Freed")) { + if !bytes.Contains(report[match:], []byte("Call Trace")) { return true } } - // When a report contains 'Call trace', 'backtrace', 'Allocated' or 'Freed' keywords, + // When a report contains 'Call Trace', 'backtrace', 'Allocated' or 'Freed' keywords, // it must also contain at least a single stack frame after the first of them. stackKeywords := []string{"Call Trace", "backtrace", "Allocated", "Freed"} stackLocation := -1 -- cgit mrf-deployment