From 1edb8cb72e7fe7912b94c12d35ea0d5a1a4bb86c Mon Sep 17 00:00:00 2001 From: Nikola Pajkovsky Date: Mon, 16 May 2011 14:02:10 +0200 Subject: reenable kernel taint abrt-dump-oops stores two new files into dump dir. kernel_tainted_short which is representation of kernel tainted value (P----T). kernel_tainted_long contains human readable strings of short version Signed-off-by: Nikola Pajkovsky --- src/include/abrt_problem_data.h | 3 + src/include/abrtlib.h | 6 ++ src/lib/Makefile.am | 1 + src/lib/kernel-tainted.c | 143 +++++++++++++++++++++++++++++++++++++ src/lib/make_descr.c | 1 + src/plugins/abrt-action-bugzilla.c | 63 ---------------- src/plugins/abrt-dump-oops.c | 14 ++++ src/plugins/rhbz.c | 19 ++--- 8 files changed, 174 insertions(+), 76 deletions(-) create mode 100644 src/lib/kernel-tainted.c diff --git a/src/include/abrt_problem_data.h b/src/include/abrt_problem_data.h index 795c2404..2fa540e3 100644 --- a/src/include/abrt_problem_data.h +++ b/src/include/abrt_problem_data.h @@ -58,6 +58,9 @@ // Optional. Set to "1" by abrt-handle-upload for every unpacked dump #define FILENAME_REMOTE "remote" #define FILENAME_TAINTED "kernel_tainted" +#define FILENAME_TAINTED_SHORT "kernel_tainted_short" +#define FILENAME_TAINTED_LONG "kernel_tainted_long" +// TODO: TicketUploader also has open-coded "TICKET", "CUSTOMER" files #define FILENAME_UUID "uuid" #define FILENAME_COUNT "count" diff --git a/src/include/abrtlib.h b/src/include/abrtlib.h index 294afdda..5d03ee49 100644 --- a/src/include/abrtlib.h +++ b/src/include/abrtlib.h @@ -283,6 +283,12 @@ bool load_conf_file(const char *pPath, map_string_h *settings, bool skipKeysWith #define steal_directory abrt_steal_directory struct dump_dir *steal_directory(const char *base_dir, const char *dump_dir_name); +#define kernel_tainted_short abrt_kernel_tainted_short +char *kernel_tainted_short(unsigned tainted); + +#define kernel_tainted_long abrt_kernel_tainted_long +GList *kernel_tainted_long(unsigned tainted); + #ifdef __cplusplus } #endif diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am index 14220c99..86210d4e 100644 --- a/src/lib/Makefile.am +++ b/src/lib/Makefile.am @@ -11,6 +11,7 @@ lib_LTLIBRARIES = \ # xconnect.cpp libreport_la_SOURCES = \ + kernel-tainted.c \ xfuncs.c \ is_in_string_list.c \ encbase64.c \ diff --git a/src/lib/kernel-tainted.c b/src/lib/kernel-tainted.c new file mode 100644 index 00000000..115e44e0 --- /dev/null +++ b/src/lib/kernel-tainted.c @@ -0,0 +1,143 @@ +/* + Copyright (C) 2011 ABRT team + Copyright (C) 2011 RedHat Inc + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#include "abrtlib.h" + +/* From RHEL6 kernel/panic.c: */ +static const int tnts_short[] = { + 'P' , + 'F' , + 'S' , + 'R' , + 'M' , + 'B' , + 'U' , + 'D' , + 'A' , + 'W' , + 'C' , + 'I' , + '-' , + '-' , + '-' , + '-' , + '-' , + '-' , + '-' , + '-' , + '-' , + '-' , + '-' , + '-' , + '-' , + '-' , + '-' , + '-' , + 'H' , + 'T' , +}; + +/** + * print_tainted - return a string to represent the kernel taint state. + * + * 'P' - Proprietary module has been loaded. + * 'F' - Module has been forcibly loaded. + * 'S' - SMP with CPUs not designed for SMP. + * 'R' - User forced a module unload. + * 'M' - System experienced a machine check exception. + * 'B' - System has hit bad_page. + * 'U' - Userspace-defined naughtiness. + * 'D' - Kernel has oopsed before + * 'A' - ACPI table overridden. + * 'W' - Taint on warning. + * 'C' - modules from drivers/staging are loaded. + * 'I' - Working around severe firmware bug. + * 'H' - Hardware is unsupported. + * T - Tech_preview + */ + + +static const char *const tnts_long[] = { + "Proprietary module has been loaded.", + "Module has been forcibly loaded.", + "SMP with CPUs not designed for SMP.", + "User forced a module unload.", + "System experienced a machine check exception.", + "System has hit bad_page.", + "Userspace-defined naughtiness.", + "Kernel has oopsed before.", + "ACPI table overridden.", + "Taint on warning.", + "Modules from drivers/staging are loaded.", + "Working around severe firmware bug.", + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + "Hardware is unsupported.", + "Tech_preview", +}; + +char *kernel_tainted_short(unsigned tainted) +{ + char *tnt = xzalloc(ARRAY_SIZE(tnts_short) + 1); + int i = 0; + while (tainted) + { + if (0x1 & tainted) + tnt[i] = tnts_short[i]; + else + tnt[i] = '-'; + + ++i; + tainted >>= 1; + } + + return tnt; +} + +GList *kernel_tainted_long(unsigned tainted) +{ + int i = 0; + GList *tnt = NULL; + + while (tainted) + { + if (0x1 & tainted && tnts_long[i]) + tnt = g_list_append(tnt, xstrdup(tnts_long[i])); + + ++i; + tainted >>= 1; + } + + return tnt; +} diff --git a/src/lib/make_descr.c b/src/lib/make_descr.c index fe629d2b..036d7770 100644 --- a/src/lib/make_descr.c +++ b/src/lib/make_descr.c @@ -237,6 +237,7 @@ static const char *const blacklisted_items[] = { FILENAME_DUPHASH , FILENAME_UUID , FILENAME_COUNT , + FILENAME_TAINTED_SHORT, NULL }; diff --git a/src/plugins/abrt-action-bugzilla.c b/src/plugins/abrt-action-bugzilla.c index ee678fe8..e56ce99b 100644 --- a/src/plugins/abrt-action-bugzilla.c +++ b/src/plugins/abrt-action-bugzilla.c @@ -24,69 +24,6 @@ #define XML_RPC_SUFFIX "/xmlrpc.cgi" -/* From RHEL6 kernel/panic.c: - * { TAINT_PROPRIETARY_MODULE, 'P', 'G' }, - * { TAINT_FORCED_MODULE, 'F', ' ' }, - * { TAINT_UNSAFE_SMP, 'S', ' ' }, - * { TAINT_FORCED_RMMOD, 'R', ' ' }, - * { TAINT_MACHINE_CHECK, 'M', ' ' }, - * { TAINT_BAD_PAGE, 'B', ' ' }, - * { TAINT_USER, 'U', ' ' }, - * { TAINT_DIE, 'D', ' ' }, - * { TAINT_OVERRIDDEN_ACPI_TABLE, 'A', ' ' }, - * { TAINT_WARN, 'W', ' ' }, - * { TAINT_CRAP, 'C', ' ' }, - * { TAINT_FIRMWARE_WORKAROUND, 'I', ' ' }, - * entries 12 - 27 are unused - * { TAINT_HARDWARE_UNSUPPORTED, 'H', ' ' }, - * entries 29 - 31 are unused - */ - -static const char * const taint_warnings[] = { - "Proprietary Module", - "Forced Module", - "Unsafe SMP", - "Forced rmmod", - "Machine Check", - "Bad Page", - "User", - "Die", - "Overriden ACPI Table", - "Warning Issued", - "Experimental Module Loaded", - "Firmware Workaround", - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - "Hardware Unsupported", - NULL, - NULL, -}; - -/* TODO: npajkovs: fix tainted string */ -static const char *tainted_string(unsigned tainted) -{ - unsigned idx = 0; - while ((tainted >>= 1) != 0) - idx++; - - return taint_warnings[idx]; -} - static void report_to_bugzilla(const char *dump_dir_name, map_string_h *settings) { struct dump_dir *dd = dd_opendir(dump_dir_name, /*flags:*/ 0); diff --git a/src/plugins/abrt-dump-oops.c b/src/plugins/abrt-dump-oops.c index c2879caa..5eba8036 100644 --- a/src/plugins/abrt-dump-oops.c +++ b/src/plugins/abrt-dump-oops.c @@ -542,7 +542,21 @@ static unsigned save_oops_to_dump_dir(GList *oops_list, unsigned oops_cnt) dd_save_text(dd, FILENAME_REASON, second_line); if (tainted_str && tainted_str[0] != '0') + { + 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); + 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); } diff --git a/src/plugins/rhbz.c b/src/plugins/rhbz.c index 83c3d20a..86cd86d7 100644 --- a/src/plugins/rhbz.c +++ b/src/plugins/rhbz.c @@ -300,8 +300,8 @@ int rhbz_new_bug(struct abrt_xmlrpc *ax, problem_data_t *problem_data, FILENAME_CRASH_FUNCTION); const char *analyzer = get_problem_item_content_or_NULL(problem_data, FILENAME_ANALYZER); - const char *tainted_str = get_problem_item_content_or_NULL(problem_data, - FILENAME_TAINTED); + const char *tainted_short = get_problem_item_content_or_NULL(problem_data, + FILENAME_TAINTED_SHORT); struct strbuf *buf_summary = strbuf_new(); strbuf_append_strf(buf_summary, "[abrt] %s", package); @@ -312,17 +312,10 @@ int rhbz_new_bug(struct abrt_xmlrpc *ax, problem_data_t *problem_data, if (reason != NULL) strbuf_append_strf(buf_summary, ": %s", reason); - if (tainted_str && analyzer - && (strcmp(analyzer, "Kerneloops") == 0) - ) { - //TODO: fix me; basically it doesn't work as it suppose to work - // I will fix it immediately when this patch land into abrt git - /* - unsigned long tainted = xatoi_positive(tainted_str); - const char *tainted_warning = tainted_string(tainted); - if (tainted_warning) - strbuf_append_strf(buf_summary, ": TAINTED %s", tainted_warning); - */ + if (tainted_short && analyzer + && (strcmp(analyzer, "Kerneloops") == 0)) + { + strbuf_append_strf(buf_summary, ": TAINTED %s", tainted_short); } char *status_whiteboard = xasprintf("abrt_hash:%s", duphash); -- cgit