Merge changes Ifaab2be0,I54df888e into main
* changes:
first_stage_console: Refactor RunScript()
first_stage_console: Fix waitpid() as SA_NOCLDWAIT
diff --git a/debuggerd/debuggerd_test.cpp b/debuggerd/debuggerd_test.cpp
index a308ffb..f396b1d 100644
--- a/debuggerd/debuggerd_test.cpp
+++ b/debuggerd/debuggerd_test.cpp
@@ -37,6 +37,7 @@
#include <string>
#include <thread>
+#include <android/crash_detail.h>
#include <android/dlext.h>
#include <android/fdsan.h>
#include <android/set_abort_message.h>
@@ -945,7 +946,7 @@
inline crash_detail_t* _Nullable android_register_crash_detail_strs(const char* _Nonnull name,
const char* _Nonnull data) {
- return android_register_crash_detail(name, strlen(name), data, strlen(data));
+ return android_crash_detail_register(name, strlen(name), data, strlen(data));
}
TEST_F(CrasherTest, crash_detail_single) {
@@ -967,6 +968,52 @@
ASSERT_MATCH(result, R"(CRASH_DETAIL_NAME: 'crash_detail_value')");
}
+TEST_F(CrasherTest, crash_detail_replace_data) {
+ int intercept_result;
+ unique_fd output_fd;
+ StartProcess([]() {
+ auto *cd = android_register_crash_detail_strs("CRASH_DETAIL_NAME", "original_data");
+ android_crash_detail_replace_data(cd, "new_data", strlen("new_data"));
+ abort();
+ });
+ StartIntercept(&output_fd);
+ FinishCrasher();
+ AssertDeath(SIGABRT);
+ FinishIntercept(&intercept_result);
+
+ ASSERT_EQ(1, intercept_result) << "tombstoned reported failure";
+
+ std::string result;
+ ConsumeFd(std::move(output_fd), &result);
+ ASSERT_MATCH(result, R"(CRASH_DETAIL_NAME: 'new_data')");
+ // Ensure the old one no longer shows up, i.e. that we actually replaced
+ // it, not added a new one.
+ ASSERT_NOT_MATCH(result, R"(CRASH_DETAIL_NAME: 'original_data')");
+}
+
+TEST_F(CrasherTest, crash_detail_replace_name) {
+ int intercept_result;
+ unique_fd output_fd;
+ StartProcess([]() {
+ auto *cd = android_register_crash_detail_strs("old_name", g_crash_detail_value);
+ android_crash_detail_replace_name(cd, "new_name", strlen("new_name"));
+ abort();
+ });
+ StartIntercept(&output_fd);
+ FinishCrasher();
+ AssertDeath(SIGABRT);
+ FinishIntercept(&intercept_result);
+
+ ASSERT_EQ(1, intercept_result) << "tombstoned reported failure";
+
+ std::string result;
+ ConsumeFd(std::move(output_fd), &result);
+ ASSERT_MATCH(result, R"(new_name: 'crash_detail_value')");
+ // Ensure the old one no longer shows up, i.e. that we actually replaced
+ // it, not added a new one.
+ ASSERT_NOT_MATCH(result, R"(old_name: 'crash_detail_value')");
+}
+
TEST_F(CrasherTest, crash_detail_single_byte_name) {
int intercept_result;
unique_fd output_fd;
@@ -991,7 +1038,7 @@
int intercept_result;
unique_fd output_fd;
StartProcess([]() {
- android_register_crash_detail("CRASH_DETAIL_NAME", strlen("CRASH_DETAIL_NAME"), "\1",
+ android_crash_detail_register("CRASH_DETAIL_NAME", strlen("CRASH_DETAIL_NAME"), "\1",
sizeof("\1"));
abort();
});
@@ -1035,7 +1082,7 @@
std::string name = "CRASH_DETAIL_NAME" + std::to_string(i);
std::string value = "CRASH_DETAIL_VALUE" + std::to_string(i);
auto* h = android_register_crash_detail_strs(name.data(), value.data());
- android_unregister_crash_detail(h);
+ android_crash_detail_unregister(h);
}
android_register_crash_detail_strs("FINAL_NAME", "FINAL_VALUE");
@@ -1103,7 +1150,7 @@
unique_fd output_fd;
StartProcess([]() {
auto* detail1 = android_register_crash_detail_strs("CRASH_DETAIL_NAME", g_crash_detail_value);
- android_unregister_crash_detail(detail1);
+ android_crash_detail_unregister(detail1);
android_register_crash_detail_strs("CRASH_DETAIL_NAME2", g_crash_detail_value2);
abort();
});
diff --git a/debuggerd/libdebuggerd/tombstone_proto.cpp b/debuggerd/libdebuggerd/tombstone_proto.cpp
index 0098209..74f9a8c 100644
--- a/debuggerd/libdebuggerd/tombstone_proto.cpp
+++ b/debuggerd/libdebuggerd/tombstone_proto.cpp
@@ -51,7 +51,7 @@
#include <android/set_abort_message.h>
#include <bionic/macros.h>
#include <bionic/reserved_signals.h>
-#include <bionic/set_abort_message_internal.h>
+#include <bionic/crash_detail_internal.h>
#include <log/log.h>
#include <log/log_read.h>
#include <log/logprint.h>
diff --git a/fs_mgr/libsnapshot/libsnapshot_cow/test_v3.cpp b/fs_mgr/libsnapshot/libsnapshot_cow/test_v3.cpp
index 3c5b394..2021348 100644
--- a/fs_mgr/libsnapshot/libsnapshot_cow/test_v3.cpp
+++ b/fs_mgr/libsnapshot/libsnapshot_cow/test_v3.cpp
@@ -109,6 +109,40 @@
ASSERT_EQ(reader.header_v3().op_count, 20);
}
+TEST_F(CowTestV3, MaxOpSingleThreadCompression) {
+ CowOptions options;
+ options.op_count_max = 20;
+ options.num_compress_threads = 1;
+ options.compression_factor = 4096 * 8;
+ options.compression = "lz4";
+
+ auto writer = CreateCowWriter(3, options, GetCowFd());
+ ASSERT_TRUE(writer->AddZeroBlocks(1, 20));
+ std::string data = "This is some data, believe it";
+ data.resize(options.block_size, '\0');
+
+ ASSERT_FALSE(writer->AddRawBlocks(5, data.data(), data.size()));
+
+ ASSERT_TRUE(writer->Finalize());
+}
+
+TEST_F(CowTestV3, MaxOpMultiThreadCompression) {
+ CowOptions options;
+ options.op_count_max = 20;
+ options.num_compress_threads = 2;
+ options.compression_factor = 4096 * 8;
+ options.compression = "lz4";
+
+ auto writer = CreateCowWriter(3, options, GetCowFd());
+ ASSERT_TRUE(writer->AddZeroBlocks(1, 20));
+ std::string data = "This is some data, believe it";
+ data.resize(options.block_size, '\0');
+
+ ASSERT_FALSE(writer->AddRawBlocks(5, data.data(), data.size()));
+
+ ASSERT_TRUE(writer->Finalize());
+}
+
TEST_F(CowTestV3, ZeroOp) {
CowOptions options;
options.op_count_max = 20;
diff --git a/fs_mgr/libsnapshot/libsnapshot_cow/writer_v3.cpp b/fs_mgr/libsnapshot/libsnapshot_cow/writer_v3.cpp
index 22e6f2c..30c5135 100644
--- a/fs_mgr/libsnapshot/libsnapshot_cow/writer_v3.cpp
+++ b/fs_mgr/libsnapshot/libsnapshot_cow/writer_v3.cpp
@@ -121,7 +121,6 @@
return false;
}
- LOG(INFO) << "Compression factor: " << header_.max_compression_size;
num_compress_threads_ = std::max(int(options_.num_compress_threads), 1);
auto parts = android::base::Split(options_.compression, ",");
if (parts.size() > 2) {
@@ -356,6 +355,9 @@
<< ", actual number of blocks received from compressor " << blocks.size();
return false;
}
+ if (!CheckOpCount(blocks.size())) {
+ return false;
+ }
size_t blocks_written = 0;
for (size_t blk_index = 0; blk_index < blocks.size(); blk_index++) {
CowOperation& op = cached_ops_.emplace_back();
@@ -395,9 +397,6 @@
}
const auto bytes = reinterpret_cast<const uint8_t*>(data);
const size_t num_blocks = (size / header_.block_size);
- if (!CheckOpCount(num_blocks)) {
- return false;
- }
for (size_t i = 0; i < num_blocks;) {
const size_t blocks_to_write =
std::min<size_t>(batch_size_ - cached_data_.size(), num_blocks - i);
diff --git a/fs_mgr/libsnapshot/snapshot.cpp b/fs_mgr/libsnapshot/snapshot.cpp
index ba5fb88..cbe8285 100644
--- a/fs_mgr/libsnapshot/snapshot.cpp
+++ b/fs_mgr/libsnapshot/snapshot.cpp
@@ -3242,6 +3242,8 @@
// Older OTAs don't set an explicit compression type, so default to gz.
compression_algorithm = "gz";
}
+ LOG(INFO) << "using compression algorithm: " << compression_algorithm
+ << ", max compressible block size: " << compression_factor;
}
PartitionCowCreator cow_creator{
diff --git a/trusty/trusty-base.mk b/trusty/trusty-base.mk
index 5aa4392..b21eca6 100644
--- a/trusty/trusty-base.mk
+++ b/trusty/trusty-base.mk
@@ -35,7 +35,6 @@
LOCAL_KEYMINT_PRODUCT_PACKAGE := android.hardware.security.keymint-service.trusty
endif
-# TODO(b/306364873): move this to be flag-controlled?
ifeq ($(SECRETKEEPER_ENABLED),true)
LOCAL_SECRETKEEPER_PRODUCT_PACKAGE := android.hardware.security.secretkeeper.trusty
else