From 9acab5a4d6df53e05b810a6b22a6bc44271cefbc Mon Sep 17 00:00:00 2001 From: Paul Crowley Date: Fri, 14 Aug 2020 11:05:05 -0700 Subject: Set ro.crypto.type even on failure Move responsibility for setting ro.crypto.type into fs_mgr_mount_all, so that even if setting up the filesystem fails, the type is set correctly and so errors are appropriately handled. Bug: 162289984 Test: simulate a failure and check that it's set. Change-Id: Ib061a454e7e21d7206c3c1fa8e88e16618099581 --- init/builtins.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'init/builtins.cpp') diff --git a/init/builtins.cpp b/init/builtins.cpp index 0b456e70a..f5de1adf1 100644 --- a/init/builtins.cpp +++ b/init/builtins.cpp @@ -570,7 +570,6 @@ static Result queue_fs_event(int code, bool userdata_remount) { trigger_shutdown("reboot,requested-userdata-remount-on-fde-device"); } SetProperty("ro.crypto.state", "encrypted"); - SetProperty("ro.crypto.type", "block"); ActionManager::GetInstance().QueueEventTrigger("defaultcrypto"); return {}; } else if (code == FS_MGR_MNTALL_DEV_NOT_ENCRYPTED) { @@ -595,7 +594,6 @@ static Result queue_fs_event(int code, bool userdata_remount) { return Error() << "FscryptInstallKeyring() failed"; } SetProperty("ro.crypto.state", "encrypted"); - SetProperty("ro.crypto.type", "file"); // Although encrypted, we have device key, so we do not need to // do anything different from the nonencrypted case. @@ -606,7 +604,6 @@ static Result queue_fs_event(int code, bool userdata_remount) { return Error() << "FscryptInstallKeyring() failed"; } SetProperty("ro.crypto.state", "encrypted"); - SetProperty("ro.crypto.type", "file"); // Although encrypted, vold has already set the device up, so we do not need to // do anything different from the nonencrypted case. @@ -617,7 +614,6 @@ static Result queue_fs_event(int code, bool userdata_remount) { return Error() << "FscryptInstallKeyring() failed"; } SetProperty("ro.crypto.state", "encrypted"); - SetProperty("ro.crypto.type", "file"); // Although encrypted, vold has already set the device up, so we do not need to // do anything different from the nonencrypted case. -- cgit v1.2.3 From 8c92256df5880072f950adc28891398dce7ffe3a Mon Sep 17 00:00:00 2001 From: Gavin Corkery Date: Mon, 11 May 2020 14:10:09 +0100 Subject: Store userspace reboot info in /metadata Store pertinent information about userspace reboot events in the case of failure. This information is any services which failed to stop cleanly, the output of the default fstab and /proc/mounts, and a list of mounts which failed to unmount. This information is only stored as necessary (i.e. mount information will not be stored if everything unmounted, even if some services failed to stop). Added new /metadata/userspacereboot directory to persist this information. Information older than 3 days will be deleted. Test: adb reboot userspace with sigterm/sigkill timeouts set to very low values Test: Manual test of storing all other information Bug: 151820675 Change-Id: I6cfbfae92a7fc6f6c984475cad2c50c559924866 --- init/builtins.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'init/builtins.cpp') diff --git a/init/builtins.cpp b/init/builtins.cpp index 0ac66f272..824bd1e78 100644 --- a/init/builtins.cpp +++ b/init/builtins.cpp @@ -1177,6 +1177,10 @@ static Result do_remount_userdata(const BuiltinArguments& args) { } // TODO(b/135984674): check that fstab contains /data. if (auto rc = fs_mgr_remount_userdata_into_checkpointing(&fstab); rc < 0) { + std::string proc_mounts_output; + android::base::ReadFileToString("/proc/mounts", &proc_mounts_output, true); + android::base::WriteStringToFile(proc_mounts_output, + "/metadata/userspacereboot/mount_info.txt"); trigger_shutdown("reboot,mount_userdata_failed"); } if (auto result = queue_fs_event(initial_mount_fstab_return_code, true); !result.ok()) { -- cgit v1.2.3 From 9ede7ec273539d7ad6820bdf3f1f2f28433a9fb3 Mon Sep 17 00:00:00 2001 From: Nikita Ioffe Date: Mon, 7 Sep 2020 10:27:25 +0100 Subject: Only store result of mount_all that mounted userdata During boot sequence there can be multiple calls to mount_all. For the userspace reboot to correctly remount userdata, we need to store the return code of the one that was responsible in mounting userdata. Test: adb root Test: adb shell setprop init.userspace_reboot.is_supported 1 Test: adb reboot userspace Test: checked dmsg Bug: 166353152 Change-Id: Id0ae15f3bcf65fa54e4e72b76f64716c053af7fb --- init/builtins.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'init/builtins.cpp') diff --git a/init/builtins.cpp b/init/builtins.cpp index 597c32d05..d00d1b121 100644 --- a/init/builtins.cpp +++ b/init/builtins.cpp @@ -662,18 +662,26 @@ static Result do_mount_all(const BuiltinArguments& args) { } } - auto mount_fstab_return_code = fs_mgr_mount_all(&fstab, mount_all->mode); + auto mount_fstab_result = fs_mgr_mount_all(&fstab, mount_all->mode); SetProperty(prop_name, std::to_string(t.duration().count())); if (mount_all->import_rc) { import_late(mount_all->rc_paths); } + if (mount_fstab_result.userdata_mounted) { + // This call to fs_mgr_mount_all mounted userdata. Keep the result in + // order for userspace reboot to correctly remount userdata. + LOG(INFO) << "Userdata mounted using " + << (mount_all->fstab_path.empty() ? "(default fstab)" : mount_all->fstab_path) + << " result : " << mount_fstab_result.code; + initial_mount_fstab_return_code = mount_fstab_result.code; + } + if (queue_event) { /* queue_fs_event will queue event based on mount_fstab return code * and return processed return code*/ - initial_mount_fstab_return_code = mount_fstab_return_code; - auto queue_fs_result = queue_fs_event(mount_fstab_return_code, false); + auto queue_fs_result = queue_fs_event(mount_fstab_result.code, false); if (!queue_fs_result.ok()) { return Error() << "queue_fs_event() failed: " << queue_fs_result.error(); } -- cgit v1.2.3