|
|
a60cd7 |
From a2cdf73fa34cf196b08932841d107a82c5bc16e5 Mon Sep 17 00:00:00 2001
|
|
|
a60cd7 |
From: Matej Habrnal <mhabrnal@redhat.com>
|
|
|
a60cd7 |
Date: Mon, 14 Aug 2017 13:34:59 +0200
|
|
|
a60cd7 |
Subject: [PATCH] koops: add suspicious strings blacklist
|
|
|
a60cd7 |
|
|
|
a60cd7 |
Some strings were accidentally considered suspicious.
|
|
|
a60cd7 |
In this concrete case strings containing "DEBUG" substring.
|
|
|
a60cd7 |
Since "BUG" and "DEBUG" overlaps and "BUG" is
|
|
|
a60cd7 |
listed in suspicious string list, kernel DEBUG messages were
|
|
|
a60cd7 |
recognized as "BUG"s which are kernel oops-es.
|
|
|
a60cd7 |
|
|
|
a60cd7 |
Added "DEBUG" string into mentioned new blacklist.
|
|
|
a60cd7 |
|
|
|
a60cd7 |
Related to rhbz#1228344
|
|
|
a60cd7 |
|
|
|
a60cd7 |
Signed-off-by: Matej Habrnal <mhabrnal@redhat.com>
|
|
|
a60cd7 |
---
|
|
|
a60cd7 |
src/include/libabrt.h | 2 ++
|
|
|
a60cd7 |
src/lib/kernel.c | 60 ++++++++++++++++++++++++++++++++++-----------------
|
|
|
a60cd7 |
2 files changed, 42 insertions(+), 20 deletions(-)
|
|
|
a60cd7 |
|
|
|
a60cd7 |
diff --git a/src/include/libabrt.h b/src/include/libabrt.h
|
|
|
a60cd7 |
index 2510a77..5346328 100644
|
|
|
a60cd7 |
--- a/src/include/libabrt.h
|
|
|
a60cd7 |
+++ b/src/include/libabrt.h
|
|
|
a60cd7 |
@@ -125,6 +125,8 @@ char *kernel_tainted_long(const char *tainted_short);
|
|
|
a60cd7 |
int koops_hash_str(char hash_str[SHA1_RESULT_LEN*2 + 1], const char *oops_buf);
|
|
|
a60cd7 |
#define koops_extract_oopses abrt_koops_extract_oopses
|
|
|
a60cd7 |
void koops_extract_oopses(GList **oops_list, char *buffer, size_t buflen);
|
|
|
a60cd7 |
+#define koops_suspicious_strings_blacklist abrt_koops_suspicious_strings_blacklist
|
|
|
a60cd7 |
+GList *koops_suspicious_strings_blacklist(void);
|
|
|
a60cd7 |
#define koops_print_suspicious_strings abrt_koops_print_suspicious_strings
|
|
|
a60cd7 |
void koops_print_suspicious_strings(void);
|
|
|
a60cd7 |
/**
|
|
|
a60cd7 |
diff --git a/src/lib/kernel.c b/src/lib/kernel.c
|
|
|
a60cd7 |
index 1a9d327..79e7424 100644
|
|
|
a60cd7 |
--- a/src/lib/kernel.c
|
|
|
a60cd7 |
+++ b/src/lib/kernel.c
|
|
|
a60cd7 |
@@ -158,11 +158,46 @@ static const char *const s_koops_suspicious_strings[] = {
|
|
|
a60cd7 |
NULL
|
|
|
a60cd7 |
};
|
|
|
a60cd7 |
|
|
|
a60cd7 |
+static const char *const s_koops_suspicious_strings_blacklist[] = {
|
|
|
a60cd7 |
+ /* "BUG:" and "DEBUG:" overlaps, we don't want to recognize DEBUG messages as BUG */
|
|
|
a60cd7 |
+ "DEBUG:",
|
|
|
a60cd7 |
+
|
|
|
a60cd7 |
+ /* Termination */
|
|
|
a60cd7 |
+ NULL
|
|
|
a60cd7 |
+};
|
|
|
a60cd7 |
+
|
|
|
a60cd7 |
+static bool suspicious_line(const char *line)
|
|
|
a60cd7 |
+{
|
|
|
a60cd7 |
+ const char *const *str = s_koops_suspicious_strings;
|
|
|
a60cd7 |
+ for ( ; *str; ++str)
|
|
|
a60cd7 |
+ if (strstr(line, *str))
|
|
|
a60cd7 |
+ break;
|
|
|
a60cd7 |
+
|
|
|
a60cd7 |
+ if (!*str)
|
|
|
a60cd7 |
+ return false;
|
|
|
a60cd7 |
+
|
|
|
a60cd7 |
+ str = s_koops_suspicious_strings_blacklist;
|
|
|
a60cd7 |
+ for ( ; *str; ++str)
|
|
|
a60cd7 |
+ if (strstr(line, *str))
|
|
|
a60cd7 |
+ break;
|
|
|
a60cd7 |
+
|
|
|
a60cd7 |
+ return !*str;
|
|
|
a60cd7 |
+}
|
|
|
a60cd7 |
+
|
|
|
a60cd7 |
void koops_print_suspicious_strings(void)
|
|
|
a60cd7 |
{
|
|
|
a60cd7 |
koops_print_suspicious_strings_filtered(NULL);
|
|
|
a60cd7 |
}
|
|
|
a60cd7 |
|
|
|
a60cd7 |
+GList *koops_suspicious_strings_blacklist(void)
|
|
|
a60cd7 |
+{
|
|
|
a60cd7 |
+ GList *strings = NULL;
|
|
|
a60cd7 |
+ for (const char *const *str = s_koops_suspicious_strings_blacklist; *str; ++str)
|
|
|
a60cd7 |
+ strings = g_list_prepend(strings, (gpointer)*str);
|
|
|
a60cd7 |
+
|
|
|
a60cd7 |
+ return strings;
|
|
|
a60cd7 |
+}
|
|
|
a60cd7 |
+
|
|
|
a60cd7 |
static bool match_any(const regex_t **res, const char *str)
|
|
|
a60cd7 |
{
|
|
|
a60cd7 |
for (const regex_t **r = res; *r != NULL; ++r)
|
|
|
a60cd7 |
@@ -312,14 +347,8 @@ next_line:
|
|
|
a60cd7 |
if (oopsstart < 0)
|
|
|
a60cd7 |
{
|
|
|
a60cd7 |
/* Find start-of-oops markers */
|
|
|
a60cd7 |
- for (const char *const *str = s_koops_suspicious_strings; *str; ++str)
|
|
|
a60cd7 |
- {
|
|
|
a60cd7 |
- if (strstr(curline, *str))
|
|
|
a60cd7 |
- {
|
|
|
a60cd7 |
- oopsstart = i;
|
|
|
a60cd7 |
- break;
|
|
|
a60cd7 |
- }
|
|
|
a60cd7 |
- }
|
|
|
a60cd7 |
+ if (suspicious_line(curline))
|
|
|
a60cd7 |
+ oopsstart = i;
|
|
|
a60cd7 |
|
|
|
a60cd7 |
if (oopsstart >= 0)
|
|
|
a60cd7 |
{
|
|
|
a60cd7 |
@@ -407,18 +436,9 @@ next_line:
|
|
|
a60cd7 |
/* kernel end-of-oops marker (not including marker itself) */
|
|
|
a60cd7 |
else if (strstr(curline, "---[ end trace"))
|
|
|
a60cd7 |
oopsend = i-1;
|
|
|
a60cd7 |
- else
|
|
|
a60cd7 |
- {
|
|
|
a60cd7 |
- /* if a new oops starts, this one has ended */
|
|
|
a60cd7 |
- for (const char *const *str = s_koops_suspicious_strings; *str; ++str)
|
|
|
a60cd7 |
- {
|
|
|
a60cd7 |
- if (strstr(curline, *str))
|
|
|
a60cd7 |
- {
|
|
|
a60cd7 |
- oopsend = i-1;
|
|
|
a60cd7 |
- break;
|
|
|
a60cd7 |
- }
|
|
|
a60cd7 |
- }
|
|
|
a60cd7 |
- }
|
|
|
a60cd7 |
+ /* if a new oops starts, this one has ended */
|
|
|
a60cd7 |
+ else if (suspicious_line(curline))
|
|
|
a60cd7 |
+ oopsend = i-1;
|
|
|
a60cd7 |
|
|
|
a60cd7 |
if (oopsend <= i)
|
|
|
a60cd7 |
{
|
|
|
a60cd7 |
--
|
|
|
a60cd7 |
1.8.3.1
|
|
|
a60cd7 |
|