summaryrefslogtreecommitdiff
path: root/recovery.cpp
diff options
context:
space:
mode:
authorTianjie Xu <xunchang@google.com>2019-08-06 12:32:05 -0700
committerBryan Ferris <bferris@google.com>2020-02-13 19:16:38 +0000
commitcd8faf7eeead6fd6ee5912ddd26dab5ab6c7dda7 (patch)
tree514f930addae708edfb05b471e8d60933c1d0d52 /recovery.cpp
parent4139a30ec532d0f0cfcd73cd929d30dc74e98597 (diff)
Force off-device package installation with FUSE
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 Test: recovery_unit_test - no new failures Change-Id: Ia5afd19854c3737110339fd59491b96708926ae5 Merged-In: I35119c2334895aa0ef4ed71b3ddd08f280c0c031
Diffstat (limited to 'recovery.cpp')
-rw-r--r--recovery.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/recovery.cpp b/recovery.cpp
index 9ea616e1..526e1a55 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -752,7 +752,11 @@ Device::BuiltinAction start_recovery(Device* device, const std::vector<std::stri
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(