crash-reporter: accept kernel dmesg records with no ramoops header

pstore compression has been added since kernel 3.12. In order to
decompress dmesg correctly, ramoops driver has to strip the header
before handing over the record to the pstore driver, so we don't
need to do it in KernelCollector anymore.

The corresponding kernel patch is at
https://chromium-review.googlesource.com/#/c/211389

BUG=chromium:392248
TEST=platform_KernelErrorPaths passed on 3.14 kernel

Change-Id: If1bec43e640e0978c7573cc90befc6d68072373c
Signed-off-by: Ben Zhang <benzh@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/211460
Reviewed-by: Kees Cook <keescook@chromium.org>
This commit is contained in:
Ben Zhang 2014-07-07 17:39:47 -07:00 committed by chrome-internal-fetch
parent d6169a2a4f
commit 8e5340a1d8
2 changed files with 10 additions and 14 deletions

View File

@ -96,14 +96,18 @@ bool KernelCollector::ReadRecordToString(std::string *contents,
return false;
}
*record_found = true;
if (record_re.FullMatch(record, &captured)) {
// Found a match, append it to the content, and remove from pstore.
contents->append(captured);
base::DeleteFile(ramoops_record, false);
*record_found = true;
} else {
*record_found = false;
// pstore compression has been added since kernel 3.12. In order to
// decompress dmesg correctly, ramoops driver has to strip the header
// before handing over the record to the pstore driver, so we don't
// need to do it here anymore.
contents->append(record);
}
base::DeleteFile(ramoops_record, false);
return true;
}

View File

@ -78,10 +78,10 @@ TEST_F(KernelCollectorTest, LoadPreservedDump) {
std::string dump;
dump.clear();
WriteStringToFile(kcrash_file(), "emptydata");
WriteStringToFile(kcrash_file(), "CrashRecordWithoutRamoopsHeader");
ASSERT_TRUE(collector_.LoadParameters());
ASSERT_FALSE(collector_.LoadPreservedDump(&dump));
ASSERT_EQ("", dump);
ASSERT_TRUE(collector_.LoadPreservedDump(&dump));
ASSERT_EQ("CrashRecordWithoutRamoopsHeader", dump);
WriteStringToFile(kcrash_file(), "====1.1\nsomething");
ASSERT_TRUE(collector_.LoadParameters());
@ -229,14 +229,6 @@ TEST_F(KernelCollectorTest, CollectPreservedFileMissing) {
ASSERT_EQ(0, s_crashes);
}
TEST_F(KernelCollectorTest, CollectNoCrash) {
WriteStringToFile(kcrash_file(), "");
ASSERT_FALSE(collector_.Collect());
ASSERT_TRUE(FindLog("No valid records found"));
ASSERT_FALSE(FindLog("Stored kcrash to "));
ASSERT_EQ(0, s_crashes);
}
TEST_F(KernelCollectorTest, CollectBadDirectory) {
WriteStringToFile(kcrash_file(), "====1.1\nsomething");
ASSERT_TRUE(collector_.Collect());