diff --git a/bootstat/bootstat.rc b/bootstat/bootstat.rc index 23f01d19b..22bd0e7a3 100644 --- a/bootstat/bootstat.rc +++ b/bootstat/bootstat.rc @@ -40,15 +40,6 @@ on post-fs-data chown system log /data/misc/bootstat/time_since_last_boot # end ota transitional support -# Record the time at which the user has successfully entered the pin to decrypt -# the device, /data is decrypted, and the system is entering the main boot phase. -# -# post-fs-data: /data is writable -# property:init.svc.bootanim=running: The boot animation is running -# property:ro.crypto.type=block: FDE device -on post-fs-data && property:init.svc.bootanim=running && property:ro.crypto.type=block - exec_background - system log -- /system/bin/bootstat -r post_decrypt_time_elapsed - # Initialize bootstat state machine. # # sys.bootstat.first_boot_completed: responsible for making sure that record_boot_complete happens diff --git a/debuggerd/libdebuggerd/gwp_asan.cpp b/debuggerd/libdebuggerd/gwp_asan.cpp index d8f74e0c1..26084dc3d 100644 --- a/debuggerd/libdebuggerd/gwp_asan.cpp +++ b/debuggerd/libdebuggerd/gwp_asan.cpp @@ -88,7 +88,7 @@ GwpAsanCrashData::GwpAsanCrashData(unwindstack::Memory* process_memory, thread_id_ = thread_info.tid; // Grab the internal error address, if it exists. - uintptr_t internal_crash_address = __gwp_asan_get_internal_crash_address(&state_); + uintptr_t internal_crash_address = __gwp_asan_get_internal_crash_address(&state_, crash_address_); if (internal_crash_address) { crash_address_ = internal_crash_address; } diff --git a/debuggerd/libdebuggerd/scudo.cpp b/debuggerd/libdebuggerd/scudo.cpp index 37e390bdc..5a62fe1e7 100644 --- a/debuggerd/libdebuggerd/scudo.cpp +++ b/debuggerd/libdebuggerd/scudo.cpp @@ -44,9 +44,12 @@ ScudoCrashData::ScudoCrashData(unwindstack::Memory* process_memory, __scudo_get_stack_depot_size()); auto region_info = AllocAndReadFully(process_memory, process_info.scudo_region_info, __scudo_get_region_info_size()); - auto ring_buffer = AllocAndReadFully(process_memory, process_info.scudo_ring_buffer, - process_info.scudo_ring_buffer_size); - if (!stack_depot || !region_info || !ring_buffer) { + std::unique_ptr ring_buffer; + if (process_info.scudo_ring_buffer_size != 0) { + ring_buffer = AllocAndReadFully(process_memory, process_info.scudo_ring_buffer, + process_info.scudo_ring_buffer_size); + } + if (!stack_depot || !region_info) { return; } diff --git a/fastboot/fastboot.cpp b/fastboot/fastboot.cpp index f1b82e9fe..9676f8779 100644 --- a/fastboot/fastboot.cpp +++ b/fastboot/fastboot.cpp @@ -1082,7 +1082,8 @@ static void flash_buf(const std::string& partition, struct fastboot_buffer* buf) sparse_file** s; if (partition == "boot" || partition == "boot_a" || partition == "boot_b" || - partition == "init_boot" || partition == "init_boot_a" || partition == "init_boot_b") { + partition == "init_boot" || partition == "init_boot_a" || partition == "init_boot_b" || + partition == "recovery" || partition == "recovery_a" || partition == "recovery_b") { copy_avb_footer(partition, buf); } diff --git a/fs_mgr/TEST_MAPPING b/fs_mgr/TEST_MAPPING index 432aa4ff5..2b5e3377c 100644 --- a/fs_mgr/TEST_MAPPING +++ b/fs_mgr/TEST_MAPPING @@ -27,5 +27,16 @@ { "name": "cow_api_test" } + ], + "kernel-presubmit": [ + { + "name": "vts_libdm_test" + }, + { + "name": "vts_core_liblp_test" + }, + { + "name": "vts_libsnapshot_test" + } ] } diff --git a/fs_mgr/fs_mgr_fstab.cpp b/fs_mgr/fs_mgr_fstab.cpp index 756fadbbc..ef7147ea9 100644 --- a/fs_mgr/fs_mgr_fstab.cpp +++ b/fs_mgr/fs_mgr_fstab.cpp @@ -305,19 +305,16 @@ bool ParseFsMgrFlags(const std::string& flags, FstabEntry* entry) { if (!ParseByteCount(arg, &entry->zram_backingdev_size)) { LWARNING << "Warning: zram_backingdev_size= flag malformed: " << arg; } - } else if (StartsWith(flag, "zoned_device=")) { - std::string zoned; - if (ReadFileToString("/sys/class/block/" + arg + "/queue/zoned", &zoned) && - android::base::StartsWith(zoned, "host-managed")) { - entry->zoned_device = "/dev/block/" + arg; + } else if (flag == "zoned_device") { + if (access("/dev/block/by-name/zoned_device", F_OK) == 0) { + entry->zoned_device = "/dev/block/by-name/zoned_device"; // atgc in f2fs does not support a zoned device auto options = Split(entry->fs_options, ","); options.erase(std::remove(options.begin(), options.end(), "atgc"), options.end()); entry->fs_options = android::base::Join(options, ","); - LINFO << "Removed ATGC in fs_options as " << entry->fs_options; - } else { - LWARNING << "Warning: cannot find the zoned device: " << arg; + LINFO << "Removed ATGC in fs_options as " << entry->fs_options + << " for zoned device=" << entry->zoned_device; } } else { LWARNING << "Warning: unknown flag: " << flag; diff --git a/fs_mgr/libfiemap/README.md b/fs_mgr/libfiemap/README.md index 62d610a5d..cdc80b28f 100644 --- a/fs_mgr/libfiemap/README.md +++ b/fs_mgr/libfiemap/README.md @@ -35,18 +35,18 @@ images. After `/data` is mounted however, there are two problems: We break the problem down into three scenarios. -### FDE and Metadata Encrypted Devices +### Metadata Encrypted Devices -When FDE or metadata encryption is used, `/data` is not mounted from +When metadata encryption is used, `/data` is not mounted from `/dev/block/by-name/data`. Instead, it is mounted from an intermediate -`dm-crypt` or `dm-default-key` device. This means the underlying device is -not marked in use, and we can create new dm-linear devices on top of it. +`dm-default-key` device. This means the underlying device is not marked in use, +and we can create new dm-linear devices on top of it. On these devices, a block device for an image will consist of a single device-mapper device with a `dm-linear` table entry for each extent in the backing file. -### Unencrypted and FBE-encrypted Devices +### Unencrypted and FBE-only Devices When a device is unencrypted, or is encrypted with FBE but not metadata encryption, we instead use a loop device with `LOOP_SET_DIRECT_IO` enabled. diff --git a/fs_mgr/libsnapshot/snapshot.cpp b/fs_mgr/libsnapshot/snapshot.cpp index 10d2f185a..961db02ef 100644 --- a/fs_mgr/libsnapshot/snapshot.cpp +++ b/fs_mgr/libsnapshot/snapshot.cpp @@ -1498,6 +1498,7 @@ void SnapshotManager::AcknowledgeMergeSuccess(LockedFile* lock) { if (UpdateUsesUserSnapshots(lock) && !device()->IsTestDevice()) { if (snapuserd_client_) { snapuserd_client_->DetachSnapuserd(); + snapuserd_client_->RemoveTransitionedDaemonIndicator(); snapuserd_client_ = nullptr; } } diff --git a/fs_mgr/libsnapshot/snapuserd/Android.bp b/fs_mgr/libsnapshot/snapuserd/Android.bp index 64e0b8aff..a67e37c1b 100644 --- a/fs_mgr/libsnapshot/snapuserd/Android.bp +++ b/fs_mgr/libsnapshot/snapuserd/Android.bp @@ -37,11 +37,13 @@ cc_defaults { cc_library_static { name: "libsnapshot_snapuserd", defaults: [ + "fs_mgr_defaults", "libsnapshot_snapuserd_defaults", ], recovery_available: true, static_libs: [ "libcutils_sockets", + "libfs_mgr", ], shared_libs: [ "libbase", @@ -49,6 +51,7 @@ cc_library_static { ], export_include_dirs: ["include"], ramdisk_available: true, + vendor_ramdisk_available: true, } cc_defaults { @@ -86,6 +89,7 @@ cc_defaults { "libgflags", "liblog", "libsnapshot_cow", + "libsnapshot_snapuserd", "libz", "liblz4", "libext4_utils", diff --git a/fs_mgr/libsnapshot/snapuserd/include/snapuserd/snapuserd_client.h b/fs_mgr/libsnapshot/snapuserd/include/snapuserd/snapuserd_client.h index 4b62b20e2..fb2251e2e 100644 --- a/fs_mgr/libsnapshot/snapuserd/include/snapuserd/snapuserd_client.h +++ b/fs_mgr/libsnapshot/snapuserd/include/snapuserd/snapuserd_client.h @@ -32,6 +32,7 @@ static constexpr uint32_t PACKET_SIZE = 512; static constexpr char kSnapuserdSocket[] = "snapuserd"; static constexpr char kSnapuserdSocketProxy[] = "snapuserd_proxy"; +static constexpr char kDaemonAliveIndicator[] = "daemon-alive-indicator"; // Ensure that the second-stage daemon for snapuserd is running. bool EnsureSnapuserdStarted(); @@ -44,9 +45,11 @@ class SnapuserdClient { std::string Receivemsg(); bool ValidateConnection(); + std::string GetDaemonAliveIndicatorPath(); public: explicit SnapuserdClient(android::base::unique_fd&& sockfd); + SnapuserdClient(){}; static std::unique_ptr Connect(const std::string& socket_name, std::chrono::milliseconds timeout_ms); @@ -91,6 +94,17 @@ class SnapuserdClient { // Check the update verification status - invoked by update_verifier during // boot bool QueryUpdateVerification(); + + // Check if Snapuser daemon is ready post selinux transition after OTA boot + // This is invoked only by init as there is no sockets setup yet during + // selinux transition + bool IsTransitionedDaemonReady(); + + // Remove the daemon-alive-indicator path post snapshot merge + bool RemoveTransitionedDaemonIndicator(); + + // Notify init that snapuserd daemon is ready post selinux transition + void NotifyTransitionDaemonIsReady(); }; } // namespace snapshot diff --git a/fs_mgr/libsnapshot/snapuserd/snapuserd_client.cpp b/fs_mgr/libsnapshot/snapuserd/snapuserd_client.cpp index e08cf9b59..695b5817f 100644 --- a/fs_mgr/libsnapshot/snapuserd/snapuserd_client.cpp +++ b/fs_mgr/libsnapshot/snapuserd/snapuserd_client.cpp @@ -29,10 +29,12 @@ #include #include +#include #include #include #include #include +#include #include namespace android { @@ -279,5 +281,42 @@ bool SnapuserdClient::QueryUpdateVerification() { return response == "success"; } +std::string SnapuserdClient::GetDaemonAliveIndicatorPath() { + return "/metadata/ota/" + std::string(kDaemonAliveIndicator); +} + +bool SnapuserdClient::IsTransitionedDaemonReady() { + if (!android::fs_mgr::WaitForFile(GetDaemonAliveIndicatorPath(), 10s)) { + LOG(ERROR) << "Timed out waiting for daemon indicator path: " + << GetDaemonAliveIndicatorPath(); + return false; + } + + return true; +} + +bool SnapuserdClient::RemoveTransitionedDaemonIndicator() { + std::string error; + std::string filePath = GetDaemonAliveIndicatorPath(); + if (!android::base::RemoveFileIfExists(filePath, &error)) { + LOG(ERROR) << "Failed to remove DaemonAliveIndicatorPath - error: " << error; + return false; + } + + if (!android::fs_mgr::WaitForFileDeleted(filePath, 5s)) { + LOG(ERROR) << "Timed out waiting for " << filePath << " to unlink"; + return false; + } + + return true; +} + +void SnapuserdClient::NotifyTransitionDaemonIsReady() { + if (!android::base::WriteStringToFile("1", GetDaemonAliveIndicatorPath())) { + PLOG(ERROR) << "Unable to write daemon alive indicator path: " + << GetDaemonAliveIndicatorPath(); + } +} + } // namespace snapshot } // namespace android diff --git a/fs_mgr/libsnapshot/snapuserd/snapuserd_daemon.cpp b/fs_mgr/libsnapshot/snapuserd/snapuserd_daemon.cpp index 2f7775cd1..bfe93ebc3 100644 --- a/fs_mgr/libsnapshot/snapuserd/snapuserd_daemon.cpp +++ b/fs_mgr/libsnapshot/snapuserd/snapuserd_daemon.cpp @@ -119,6 +119,12 @@ bool Daemon::StartServerForUserspaceSnapshots(int arg_start, int argc, char** ar } } + // We reach this point only during selinux transition during device boot. + // At this point, all threads are spin up and are ready to serve the I/O + // requests for dm-user. Lets inform init. + auto client = std::make_unique(); + client->NotifyTransitionDaemonIsReady(); + // Skip the accept() call to avoid spurious log spam. The server will still // run until all handlers have completed. return user_server_.WaitForSocket(); diff --git a/init/Android.bp b/init/Android.bp index c7e7de850..1aba4b381 100644 --- a/init/Android.bp +++ b/init/Android.bp @@ -454,15 +454,7 @@ cc_test { defaults: ["init_defaults"], require_root: true, - compile_multilib: "both", - multilib: { - lib32: { - suffix: "32", - }, - lib64: { - suffix: "64", - }, - }, + compile_multilib: "first", srcs: [ "devices_test.cpp", diff --git a/init/AndroidTest.xml b/init/AndroidTest.xml index 6f22ab792..8b05484a0 100644 --- a/init/AndroidTest.xml +++ b/init/AndroidTest.xml @@ -22,7 +22,6 @@