summaryrefslogtreecommitdiff
path: root/recovery.cpp
diff options
context:
space:
mode:
authorTianjie Xu <xunchang@google.com>2019-08-06 12:32:05 -0700
committerTianjie Xu <xunchang@google.com>2019-10-16 11:35:17 -0700
commit58a27693b22da9b93c634d053a53deb4c4a71e4e (patch)
treecba636e772425eb8680c6b9356cc4a749425c232 /recovery.cpp
parent5afb9a1f11a3b3d8437e931d19d33c492106feac (diff)
Force package installation with FUSE unless the package stores on device
The non-A/B package installation is subject to TOC/TOU flaw if the attacker can switch the package in the middle of installation. And the most pratical case is to store the package on an external device, e.g. a sdcard, and swap the device in the middle. To prevent that, we can adopt the same protection as used in sideloading a package with FUSE. Specifically, when we install the package with FUSE, we read the entire package to cryptographically verify its signature. The hash for each transfer block is recorded in the memory (TOC), and the subsequent reads (TOU) will be rejected upon dectecting a mismatch. This CL forces the package installation with FUSE when the package stays on a removable media. Bug: 136498130 Test: Run bin/recovery --update_package with various paths; and packages are installed from FUSE as expected Change-Id: Ibc9b095036a2fa624e8edf6c347ed4f12aef072f
Diffstat (limited to 'recovery.cpp')
-rw-r--r--recovery.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/recovery.cpp b/recovery.cpp
index 682ddbc4..8f8f7dc0 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -733,13 +733,11 @@ Device::BuiltinAction start_recovery(Device* device, const std::vector<std::stri
set_retry_bootloader_message(retry_count + 1, args);
}
- if (update_package[0] == '@') {
- ensure_path_mounted(update_package + 1);
- } else {
- ensure_path_mounted(update_package);
- }
-
- if (install_with_fuse) {
+ bool should_use_fuse = false;
+ if (!SetupPackageMount(update_package, &should_use_fuse)) {
+ LOG(INFO) << "Failed to set up the package access, skipping installation";
+ status = INSTALL_ERROR;
+ } else if (install_with_fuse || should_use_fuse) {
LOG(INFO) << "Installing package " << update_package << " with fuse";
status = InstallWithFuseFromPath(update_package, ui);
} else if (auto memory_package = Package::CreateMemoryPackage(