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