diff options
author | Nikola Pajkovsky <npajkovs@redhat.com> | 2010-11-25 12:14:48 +0100 |
---|---|---|
committer | Nikola Pajkovsky <npajkovs@redhat.com> | 2010-11-25 12:14:48 +0100 |
commit | 74c0a596d5b679237c1f3fba90e076a90a3b009b (patch) | |
tree | 7c06503d72a00a3f04f37526b63286d029b42ed1 | |
parent | c10a64020b11dac3438210a067ef73e674fea2ca (diff) | |
download | abrt-74c0a596d5b679237c1f3fba90e076a90a3b009b.tar.gz abrt-74c0a596d5b679237c1f3fba90e076a90a3b009b.tar.xz abrt-74c0a596d5b679237c1f3fba90e076a90a3b009b.zip |
backport: taint flag is decimal representation of a bitmask
Signed-off-by: Nikola Pajkovsky <npajkovs@redhat.com>
-rw-r--r-- | lib/Plugins/Bugzilla.cpp | 76 | ||||
-rw-r--r-- | lib/Plugins/KerneloopsScanner.cpp | 18 |
2 files changed, 78 insertions, 16 deletions
diff --git a/lib/Plugins/Bugzilla.cpp b/lib/Plugins/Bugzilla.cpp index e4255d2e..a956c89d 100644 --- a/lib/Plugins/Bugzilla.cpp +++ b/lib/Plugins/Bugzilla.cpp @@ -387,6 +387,68 @@ int ctx::add_comment(xmlrpc_int32 bug_id, const char* comment, bool is_private) return result ? 0 : -1; } +/* 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, +}; + +static const char *tainted_string(unsigned tainted) +{ + unsigned idx = 0; + while ((tainted >>= 1) != 0) + idx++; + + return taint_warnings[idx]; +} + xmlrpc_int32 ctx::new_bug(const map_crash_data_t& pCrashData, int depend_on_bugno) { const std::string& package = get_crash_data_item_content(pCrashData, FILENAME_PACKAGE); @@ -397,7 +459,7 @@ xmlrpc_int32 ctx::new_bug(const map_crash_data_t& pCrashData, int depend_on_bugn const char *reason = get_crash_data_item_content_or_NULL(pCrashData, FILENAME_REASON); const char *function = get_crash_data_item_content_or_NULL(pCrashData, FILENAME_CRASH_FUNCTION); const char *analyzer = get_crash_data_item_content_or_NULL(pCrashData, FILENAME_ANALYZER); - const char *tainted = get_crash_data_item_content_or_NULL(pCrashData, FILENAME_TAINTED); + const char *tainted_str = get_crash_data_item_content_or_NULL(pCrashData, FILENAME_TAINTED); std::string summary = "[abrt] " + package; if (function != NULL && strlen(function) < 30) @@ -412,12 +474,16 @@ xmlrpc_int32 ctx::new_bug(const map_crash_data_t& pCrashData, int depend_on_bugn summary += reason; } - if (tainted && analyzer - && (tainted[0] == '1') + if (tainted_str && analyzer && (strcmp(analyzer, "Kerneloops") == 0) ) { - summary += ": "; - summary += "TAINTED"; + unsigned long tainted = xatoi_u(tainted_str); + const char *tainted_warning = tainted_string(tainted); + if (tainted_warning) + { + summary += ": TAINTED"; + summary += tainted_warning; + } } std::string status_whiteboard = "abrt_hash:" + duphash; diff --git a/lib/Plugins/KerneloopsScanner.cpp b/lib/Plugins/KerneloopsScanner.cpp index 3731959b..6e685044 100644 --- a/lib/Plugins/KerneloopsScanner.cpp +++ b/lib/Plugins/KerneloopsScanner.cpp @@ -122,16 +122,12 @@ void save_oops_to_debug_dump(const vector_string_t& oopsList) VERB1 log("Saving %u oopses as crash dump dirs", idx >= countdown ? countdown-1 : idx); - char tainted[2] = {'x', '\0'}; - /* once tainted flag is set to 1, only restart can reset the flag to 0 */ - int tainted_fd = open("/proc/sys/kernel/tainted", O_RDONLY); - if (tainted_fd > 0) + char *tainted_str = NULL; + FILE *tainted_fd = fopen("/proc/sys/kernel/tainted", "r"); + if (tainted_fd) { - /* contain only 0 or 1 */ - if (read(tainted_fd, &tainted, 1) != 1) - error_msg("Unable to read one byte from /proc/sys/kernel/tainted"); - - close(tainted_fd); + tainted_str = xmalloc_fgetline(tainted_fd); + fclose(tainted_fd); } else error_msg("/proc/sys/kernel/tainted does not exist"); @@ -157,8 +153,8 @@ void save_oops_to_debug_dump(const vector_string_t& oopsList) /* Optional, makes generated bz more informative */ strchrnul(second_line, '\n')[0] = '\0'; dd.SaveText(FILENAME_REASON, second_line); - if (tainted[0] == '1') - dd.SaveText(FILENAME_TAINTED, tainted); + if (tainted_str[0] == '1') + dd.SaveText(FILENAME_TAINTED, tainted_str); } catch (CABRTException& e) { |