Blob Blame History Raw
From 82b27dca87ef5a4f1cbb29377524bbdee26b1d64 Mon Sep 17 00:00:00 2001
Message-Id: <82b27dca87ef5a4f1cbb29377524bbdee26b1d64.1317979766.git.npajkovs@redhat.com>
From: Nikola Pajkovsky <npajkovs@redhat.com>
Date: Wed, 5 Oct 2011 15:13:23 +0200
Subject: [PATCH 1/2] rhbz#724838 - don't file kernel bugs if "tainted: B" is
 set

Kernel maintainers are not much happy that we filling bugs when kernel
is tainted.

Dave Jones said
---
If something has corrupted memory, we typically see a whole bunch of things
start crashing. This leads to situations where abrt files a lot of bugs, even
though most of them are just fallout from the first.

an example: bugs 710925 710930 710932 710933 710935 710942 710948 710955 710956
are all the same crash. The traces and addresses are different, but 'something
scribbled over memory' is the root cause here. Sadly out of all those bugs, we
actually somehow missed the first crash which is the most relevant one. (That
one would have not had the 'Tainted: G B' text)
---

First part of the patch is that we won't relay on /proc/sys/kernel/tainted and
we will parse the kernel bt manually, because of reading that file after an oops
is ALWAYS going to show it as tainted.

Second part of the patch is that whenever you want to prohibit reporting, put a
file with name *not-reportable* into <dump-dir>. That file could be empty or with
reasonable message why are you trying to prohibit reporting.

All 3 reporters plugins will be respect that file and it won't try to report anything.
Reporters will show only the messages from *not-reportable* and *reason*.

Signed-off-by: Nikola Pajkovsky <npajkovs@redhat.com>
---
 src/gui-gtk/main.c           |   16 ++++++++--
 src/plugins/abrt-dump-oops.c |   65 +++++++++++++++++++++++------------------
 2 files changed, 49 insertions(+), 32 deletions(-)

diff --git a/src/gui-gtk/main.c b/src/gui-gtk/main.c
index 8172951..d11bf57 100644
--- a/src/gui-gtk/main.c
+++ b/src/gui-gtk/main.c
@@ -100,7 +100,14 @@ static void add_directory_to_dirlist(const char *dirname)
     }
     free(time_str);
 
-    char *reason = dd_load_text(dd, FILENAME_REASON);
+
+    char *not_reportable_reason = dd_load_text_ext(dd, FILENAME_NOT_REPORTABLE, 0
+                                                   | DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE
+                                                   | DD_FAIL_QUIETLY_ENOENT
+                                                   | DD_FAIL_QUIETLY_EACCES);
+    char *reason = NULL;
+    if (!not_reportable_reason)
+        reason = dd_load_text(dd, FILENAME_REASON);
 
     /* the source of the problem:
      * - first we try to load component, as we use it on Fedora
@@ -142,7 +149,7 @@ static void add_directory_to_dirlist(const char *dirname)
     gtk_list_store_append(list_store, &iter);
     gtk_list_store_set(list_store, &iter,
                           COLUMN_SOURCE, source,
-                          COLUMN_REASON, reason,
+                          COLUMN_REASON, not_reportable_reason? :reason,
                           //OPTION: time format
                           COLUMN_LATEST_CRASH_STR, time_buf,
                           COLUMN_LATEST_CRASH, t,
@@ -150,6 +157,7 @@ static void add_directory_to_dirlist(const char *dirname)
                           COLUMN_REPORTED_TO, msg ? subm_status : NULL,
                           -1);
     /* this is safe, subm_status is either null or malloced string from get_last_line */
+    free(not_reportable_reason);
     free(subm_status);
     free(msg);
     free(reason);
@@ -243,7 +251,9 @@ static void on_row_activated_cb(GtkTreeView *treeview, GtkTreePath *path, GtkTre
             gtk_tree_model_get_value(store, &iter, COLUMN_DUMP_DIR, &d_dir);
 
             const char *dirname = g_value_get_string(&d_dir);
-            report_problem_in_dir(dirname, LIBREPORT_ANALYZE | LIBREPORT_NOWAIT | LIBREPORT_GETPID);
+
+            report_problem_in_dir(dirname,
+                                  LIBREPORT_ANALYZE | LIBREPORT_NOWAIT | LIBREPORT_GETPID);
         }
     }
 }
diff --git a/src/plugins/abrt-dump-oops.c b/src/plugins/abrt-dump-oops.c
index 76c699d..58af506 100644
--- a/src/plugins/abrt-dump-oops.c
+++ b/src/plugins/abrt-dump-oops.c
@@ -480,16 +480,6 @@ static unsigned save_oops_to_dump_dir(GList *oops_list, unsigned oops_cnt)
 
     VERB1 log("Saving %u oopses as dump dirs", idx >= countdown ? countdown-1 : idx);
 
-    char *tainted_str = NULL;
-    FILE *tainted_fp = fopen("/proc/sys/kernel/tainted", "r");
-    if (tainted_fp)
-    {
-        tainted_str = xmalloc_fgetline(tainted_fp);
-        fclose(tainted_fp);
-    }
-    else
-        perror_msg("Can't open '%s'", "/proc/sys/kernel/tainted");
-
     char *cmdline_str = NULL;
     FILE *cmdline_fp = fopen("/proc/cmdline", "r");
     if (cmdline_fp)
@@ -536,35 +526,44 @@ static unsigned save_oops_to_dump_dir(GList *oops_list, unsigned oops_cnt)
             if (cmdline_str)
                 dd_save_text(dd, FILENAME_CMDLINE, cmdline_str);
             dd_save_text(dd, FILENAME_BACKTRACE, second_line);
-// TODO: add "Kernel oops: " prefix, so that all oopses have recognizable FILENAME_REASON?
-// kernel oops 1st line may look quite puzzling otherwise...
-            strchrnul(second_line, '\n')[0] = '\0';
-            dd_save_text(dd, FILENAME_REASON, second_line);
 
-            if (tainted_str && tainted_str[0] != '0')
+            char *tainted_short = kernel_tainted_short(second_line);
+            if (tainted_short)
             {
-                unsigned long tainted = xatoi_positive(tainted_str);
-                char *tainted_short = kernel_tainted_short(tainted);
-                GList *tainted_long = kernel_tainted_long(tainted);
-
-                struct strbuf *tnt_long = strbuf_new();
-                for (GList *li = tainted_long; li; li = li->next)
-                    strbuf_append_strf(tnt_long, "%s\n", (char*) li->data);
-
-                dd_save_text(dd, FILENAME_TAINTED, tainted_str);
+                VERB1 log("Kernel is tainted '%s'", tainted_short);
                 dd_save_text(dd, FILENAME_TAINTED_SHORT, tainted_short);
-                dd_save_text(dd, FILENAME_TAINTED_LONG, tnt_long->buf);
-                strbuf_free(tnt_long);
-                list_free_with_free(tainted_long);
+                char *reason = xasprintf("Your kernel is tainted by flags '%s'. "
+                                         "Kernel maintainers are not interesting about "
+                                         "tainted kernel, because the trace might not be showing "
+                                         "the root problem."
+                                         , tainted_short);
+                dd_save_text(dd, FILENAME_NOT_REPORTABLE, reason);
+                free(reason);
             }
+// TODO: add "Kernel oops: " prefix, so that all oopses have recognizable FILENAME_REASON?
+// kernel oops 1st line may look quite puzzling otherwise...
+            strchrnul(second_line, '\n')[0] = '\0';
+            dd_save_text(dd, FILENAME_REASON, second_line);
 
+/*
+            GList *tainted_long = kernel_tainted_long(tainted);
+
+            struct strbuf *tnt_long = strbuf_new();
+            for (GList *li = tainted_long; li; li = li->next)
+                strbuf_append_strf(tnt_long, "%s\n", (char*) li->data);
+
+            dd_save_text(dd, FILENAME_TAINTED, tainted_str);
+            dd_save_text(dd, FILENAME_TAINTED_SHORT, tainted_short);
+            dd_save_text(dd, FILENAME_TAINTED_LONG, tnt_long->buf);
+            strbuf_free(tnt_long);
+            list_free_with_free(tainted_long);
+*/
             dd_close(dd);
         }
         else
             errors++;
     }
 
-    free(tainted_str);
     free(cmdline_str);
 
     return errors;
@@ -718,7 +717,15 @@ int main(int argc, char **argv)
             {
                 int i = 0;
                 while (i < oops_cnt)
-                    printf("\nVersion: %s", (char*)g_list_nth_data(oops_list, i++));
+                {
+                    char *kernel_bt = (char*)g_list_nth_data(oops_list, i++);
+                    char *tainted_short = kernel_tainted_short(kernel_bt);
+                    if (tainted_short)
+                        log("Kernel is tainted '%s'", tainted_short);
+
+                    free(tainted_short);
+                    printf("\nVersion: %s", kernel_bt);
+                }
             }
             if ((opts & OPT_d) || (opts & OPT_D))
             {
-- 
1.7.7.rc0.70.g82660