blob: 5e5eac7abaaf4f5dbc1afe03578d0611c268edac [file] [log] [blame]
Tao Bao7197ee02015-12-05 21:21:27 -08001/*
2 * Copyright (C) 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/*
Tao Bao1cc03512018-04-18 17:10:49 -070018 * update_verifier verifies the integrity of the partitions after an A/B OTA update. It gets invoked
19 * by init, and will only perform the verification if it's the first boot post an A/B OTA update
20 * (https://source.android.com/devices/tech/ota/ab/#after_reboot).
Tao Bao7197ee02015-12-05 21:21:27 -080021 *
Tao Bao1cc03512018-04-18 17:10:49 -070022 * update_verifier relies on device-mapper-verity (dm-verity) to capture any corruption on the
23 * partitions being verified (https://source.android.com/security/verifiedboot). The verification
24 * will be skipped, if dm-verity is not enabled on the device.
25 *
26 * Upon detecting verification failures, the device will be rebooted, although the trigger of the
27 * reboot depends on the dm-verity mode.
Tianjie Xu3958a952017-03-01 15:31:25 -080028 * enforcing mode: dm-verity reboots the device
29 * eio mode: dm-verity fails the read and update_verifier reboots the device
30 * other mode: not supported and update_verifier reboots the device
31 *
Tao Bao1cc03512018-04-18 17:10:49 -070032 * All these reboots prevent the device from booting into a known corrupt state. If the device
33 * continuously fails to boot into the new slot, the bootloader should mark the slot as unbootable
34 * and trigger a fallback to the old slot.
Tao Bao7197ee02015-12-05 21:21:27 -080035 *
Tao Bao1cc03512018-04-18 17:10:49 -070036 * The current slot will be marked as having booted successfully if the verifier reaches the end
37 * after the verification.
Tao Bao7197ee02015-12-05 21:21:27 -080038 */
39
Tao Bao83b07802017-04-26 14:30:56 -070040#include "update_verifier/update_verifier.h"
Daniel Rosenberg15f22bd2019-01-22 19:57:28 -080041#include <android/os/IVold.h>
Tao Bao83b07802017-04-26 14:30:56 -070042
Tianjie Xub0ac8722017-01-18 18:41:53 -080043#include <dirent.h>
Tianjie Xud007cf22016-02-29 16:08:06 -080044#include <errno.h>
45#include <fcntl.h>
46#include <stdio.h>
Tao Bao7197ee02015-12-05 21:21:27 -080047#include <string.h>
Tianjie Xu3958a952017-03-01 15:31:25 -080048#include <unistd.h>
Tao Bao7197ee02015-12-05 21:21:27 -080049
Tianjie Xu8fa8f0b2017-04-27 11:47:35 -070050#include <algorithm>
Wei Wang5226f472017-08-02 10:27:31 -070051#include <future>
Tianjie Xud007cf22016-02-29 16:08:06 -080052
53#include <android-base/file.h>
Tianjie Xu7b0ad9c2016-08-05 18:00:04 -070054#include <android-base/logging.h>
Tianjie Xud007cf22016-02-29 16:08:06 -080055#include <android-base/parseint.h>
Tao Bao4f8d2172017-01-13 15:36:32 -080056#include <android-base/properties.h>
Tianjie Xud007cf22016-02-29 16:08:06 -080057#include <android-base/strings.h>
58#include <android-base/unique_fd.h>
Connor O'Brienad43d2d2016-11-21 12:47:33 -080059#include <android/hardware/boot/1.0/IBootControl.h>
Daniel Rosenberg15f22bd2019-01-22 19:57:28 -080060#include <binder/BinderService.h>
61#include <binder/Status.h>
Tianjie Xu3958a952017-03-01 15:31:25 -080062#include <cutils/android_reboot.h>
Connor O'Brienad43d2d2016-11-21 12:47:33 -080063
Tianjie Xu4d9e62d2018-05-11 10:41:44 -070064#include "care_map.pb.h"
Tao Bao160514b2017-11-04 00:08:08 -070065
Connor O'Brienad43d2d2016-11-21 12:47:33 -080066using android::sp;
67using android::hardware::boot::V1_0::IBootControl;
68using android::hardware::boot::V1_0::BoolResult;
69using android::hardware::boot::V1_0::CommandResult;
Tao Bao7197ee02015-12-05 21:21:27 -080070
Tianjie Xu9eed65e2018-09-14 12:52:02 -070071constexpr const char* kDefaultCareMapPrefix = "/data/ota_package/care_map";
72
Tianjie Xub0ac8722017-01-18 18:41:53 -080073// Find directories in format of "/sys/block/dm-X".
74static int dm_name_filter(const dirent* de) {
75 if (android::base::StartsWith(de->d_name, "dm-")) {
76 return 1;
77 }
78 return 0;
79}
80
Tianjie Xu9eed65e2018-09-14 12:52:02 -070081UpdateVerifier::UpdateVerifier()
82 : care_map_prefix_(kDefaultCareMapPrefix),
83 property_reader_([](const std::string& id) { return android::base::GetProperty(id, ""); }) {}
84
Tianjie Xu446b64b2018-09-19 15:45:28 -070085// Iterate the content of "/sys/block/dm-X/dm/name" and find all the dm-wrapped block devices.
86// We will later read all the ("cared") blocks from "/dev/block/dm-X" to ensure the target
87// partition's integrity.
88std::map<std::string, std::string> UpdateVerifier::FindDmPartitions() {
Tao Bao83b07802017-04-26 14:30:56 -070089 static constexpr auto DM_PATH_PREFIX = "/sys/block/";
Tianjie Xub0ac8722017-01-18 18:41:53 -080090 dirent** namelist;
91 int n = scandir(DM_PATH_PREFIX, &namelist, dm_name_filter, alphasort);
92 if (n == -1) {
93 PLOG(ERROR) << "Failed to scan dir " << DM_PATH_PREFIX;
Tianjie Xu446b64b2018-09-19 15:45:28 -070094 return {};
Tianjie Xub0ac8722017-01-18 18:41:53 -080095 }
96 if (n == 0) {
Tianjie Xu446b64b2018-09-19 15:45:28 -070097 LOG(ERROR) << "No dm block device found.";
98 return {};
Tianjie Xub0ac8722017-01-18 18:41:53 -080099 }
100
Tao Bao83b07802017-04-26 14:30:56 -0700101 static constexpr auto DM_PATH_SUFFIX = "/dm/name";
102 static constexpr auto DEV_PATH = "/dev/block/";
Tianjie Xu446b64b2018-09-19 15:45:28 -0700103 std::map<std::string, std::string> dm_block_devices;
Tianjie Xub0ac8722017-01-18 18:41:53 -0800104 while (n--) {
105 std::string path = DM_PATH_PREFIX + std::string(namelist[n]->d_name) + DM_PATH_SUFFIX;
106 std::string content;
107 if (!android::base::ReadFileToString(path, &content)) {
108 PLOG(WARNING) << "Failed to read " << path;
David Zeuthen8ed97382017-05-08 13:41:28 -0400109 } else {
110 std::string dm_block_name = android::base::Trim(content);
David Zeuthen8ed97382017-05-08 13:41:28 -0400111 // AVB is using 'vroot' for the root block device but we're expecting 'system'.
112 if (dm_block_name == "vroot") {
113 dm_block_name = "system";
Tianjie Xub0ac8722017-01-18 18:41:53 -0800114 }
Tianjie Xu446b64b2018-09-19 15:45:28 -0700115
116 dm_block_devices.emplace(dm_block_name, DEV_PATH + std::string(namelist[n]->d_name));
Tianjie Xub0ac8722017-01-18 18:41:53 -0800117 }
118 free(namelist[n]);
119 }
120 free(namelist);
121
Tianjie Xu446b64b2018-09-19 15:45:28 -0700122 return dm_block_devices;
123}
Tao Bao4f8d2172017-01-13 15:36:32 -0800124
Tianjie Xu446b64b2018-09-19 15:45:28 -0700125bool UpdateVerifier::ReadBlocks(const std::string partition_name,
126 const std::string& dm_block_device, const RangeSet& ranges) {
Tao Bao160514b2017-11-04 00:08:08 -0700127 // RangeSet::Split() splits the ranges into multiple groups with same number of blocks (except for
128 // the last group).
129 size_t thread_num = std::thread::hardware_concurrency() ?: 4;
130 std::vector<RangeSet> groups = ranges.Split(thread_num);
Tao Bao4f8d2172017-01-13 15:36:32 -0800131
Wei Wang5226f472017-08-02 10:27:31 -0700132 std::vector<std::future<bool>> threads;
Tao Bao160514b2017-11-04 00:08:08 -0700133 for (const auto& group : groups) {
Tianjie Xu446b64b2018-09-19 15:45:28 -0700134 auto thread_func = [&group, &dm_block_device, &partition_name]() {
Wei Wang5226f472017-08-02 10:27:31 -0700135 android::base::unique_fd fd(TEMP_FAILURE_RETRY(open(dm_block_device.c_str(), O_RDONLY)));
136 if (fd.get() == -1) {
Tianjie Xu446b64b2018-09-19 15:45:28 -0700137 PLOG(ERROR) << "Error reading " << dm_block_device << " for partition " << partition_name;
Tianjie Xu8fa8f0b2017-04-27 11:47:35 -0700138 return false;
139 }
Wei Wang5226f472017-08-02 10:27:31 -0700140
Tao Bao160514b2017-11-04 00:08:08 -0700141 static constexpr size_t kBlockSize = 4096;
142 std::vector<uint8_t> buf(1024 * kBlockSize);
Wei Wang5226f472017-08-02 10:27:31 -0700143
Tao Bao160514b2017-11-04 00:08:08 -0700144 size_t block_count = 0;
Tianjie Xu446b64b2018-09-19 15:45:28 -0700145 for (const auto& [range_start, range_end] : group) {
Wei Wang5226f472017-08-02 10:27:31 -0700146 if (lseek64(fd.get(), static_cast<off64_t>(range_start) * kBlockSize, SEEK_SET) == -1) {
147 PLOG(ERROR) << "lseek to " << range_start << " failed";
148 return false;
149 }
150
151 size_t remain = (range_end - range_start) * kBlockSize;
152 while (remain > 0) {
153 size_t to_read = std::min(remain, 1024 * kBlockSize);
154 if (!android::base::ReadFully(fd.get(), buf.data(), to_read)) {
155 PLOG(ERROR) << "Failed to read blocks " << range_start << " to " << range_end;
156 return false;
157 }
158 remain -= to_read;
159 }
Tao Bao160514b2017-11-04 00:08:08 -0700160 block_count += (range_end - range_start);
Wei Wang5226f472017-08-02 10:27:31 -0700161 }
Tao Bao160514b2017-11-04 00:08:08 -0700162 LOG(INFO) << "Finished reading " << block_count << " blocks on " << dm_block_device;
Wei Wang5226f472017-08-02 10:27:31 -0700163 return true;
164 };
165
166 threads.emplace_back(std::async(std::launch::async, thread_func));
Tao Bao4f8d2172017-01-13 15:36:32 -0800167 }
Tianjie Xud007cf22016-02-29 16:08:06 -0800168
Wei Wang5226f472017-08-02 10:27:31 -0700169 bool ret = true;
170 for (auto& t : threads) {
171 ret = t.get() && ret;
172 }
173 LOG(INFO) << "Finished reading blocks on " << dm_block_device << " with " << thread_num
174 << " threads.";
175 return ret;
Tianjie Xud007cf22016-02-29 16:08:06 -0800176}
177
Tianjie Xu446b64b2018-09-19 15:45:28 -0700178bool UpdateVerifier::VerifyPartitions() {
179 auto dm_block_devices = FindDmPartitions();
180 if (dm_block_devices.empty()) {
181 LOG(ERROR) << "No dm-enabled block device is found.";
Tao Bao5a1dee02017-07-21 15:15:31 -0700182 return false;
183 }
184
Tianjie Xu446b64b2018-09-19 15:45:28 -0700185 for (const auto& [partition_name, ranges] : partition_map_) {
186 if (dm_block_devices.find(partition_name) == dm_block_devices.end()) {
187 LOG(ERROR) << "Failed to find dm block device for " << partition_name;
188 return false;
Tao Bao5a1dee02017-07-21 15:15:31 -0700189 }
Tianjie Xu446b64b2018-09-19 15:45:28 -0700190
191 if (!ReadBlocks(partition_name, dm_block_devices.at(partition_name), ranges)) {
Tao Bao5a1dee02017-07-21 15:15:31 -0700192 return false;
193 }
194 }
195
196 return true;
Tianjie Xud007cf22016-02-29 16:08:06 -0800197}
198
Tianjie Xu446b64b2018-09-19 15:45:28 -0700199bool UpdateVerifier::ParseCareMapPlainText(const std::string& content) {
200 // care_map file has up to six lines, where every two lines make a pair. Within each pair, the
201 // first line has the partition name (e.g. "system"), while the second line holds the ranges of
202 // all the blocks to verify.
203 auto lines = android::base::Split(android::base::Trim(content), "\n");
204 if (lines.size() != 2 && lines.size() != 4 && lines.size() != 6) {
205 LOG(WARNING) << "Invalid lines in care_map: found " << lines.size()
206 << " lines, expecting 2 or 4 or 6 lines.";
207 return false;
208 }
209
210 for (size_t i = 0; i < lines.size(); i += 2) {
211 const std::string& partition_name = lines[i];
212 const std::string& range_str = lines[i + 1];
213 // We're seeing an N care_map.txt. Skip the verification since it's not compatible with O
214 // update_verifier (the last few metadata blocks can't be read via device mapper).
215 if (android::base::StartsWith(partition_name, "/dev/block/")) {
216 LOG(WARNING) << "Found legacy care_map.txt; skipped.";
217 return false;
218 }
219
220 // For block range string, first integer 'count' equals 2 * total number of valid ranges,
221 // followed by 'count' number comma separated integers. Every two integers reprensent a
222 // block range with the first number included in range but second number not included.
223 // For example '4,64536,65343,74149,74150' represents: [64536,65343) and [74149,74150).
224 RangeSet ranges = RangeSet::Parse(range_str);
225 if (!ranges) {
226 LOG(WARNING) << "Error parsing RangeSet string " << range_str;
227 return false;
228 }
229
230 partition_map_.emplace(partition_name, ranges);
231 }
232
233 return true;
234}
235
Tianjie Xu9eed65e2018-09-14 12:52:02 -0700236bool UpdateVerifier::ParseCareMap() {
Tianjie Xu446b64b2018-09-19 15:45:28 -0700237 partition_map_.clear();
238
Tianjie Xu9eed65e2018-09-14 12:52:02 -0700239 std::string care_map_name = care_map_prefix_ + ".pb";
240 if (access(care_map_name.c_str(), R_OK) == -1) {
241 LOG(WARNING) << care_map_name
242 << " doesn't exist, falling back to read the care_map in plain text format.";
243 care_map_name = care_map_prefix_ + ".txt";
Tianjie Xu446b64b2018-09-19 15:45:28 -0700244 }
245
Tianjie Xu4d9e62d2018-05-11 10:41:44 -0700246 android::base::unique_fd care_map_fd(TEMP_FAILURE_RETRY(open(care_map_name.c_str(), O_RDONLY)));
247 // If the device is flashed before the current boot, it may not have care_map.txt in
248 // /data/ota_package. To allow the device to continue booting in this situation, we should
249 // print a warning and skip the block verification.
250 if (care_map_fd.get() == -1) {
251 PLOG(WARNING) << "Failed to open " << care_map_name;
Tianjie Xu446b64b2018-09-19 15:45:28 -0700252 return false;
Tianjie Xu4d9e62d2018-05-11 10:41:44 -0700253 }
254
255 std::string file_content;
256 if (!android::base::ReadFdToString(care_map_fd.get(), &file_content)) {
Tianjie Xu446b64b2018-09-19 15:45:28 -0700257 PLOG(WARNING) << "Failed to read " << care_map_name;
Tianjie Xu4d9e62d2018-05-11 10:41:44 -0700258 return false;
259 }
260
261 if (file_content.empty()) {
Tianjie Xu446b64b2018-09-19 15:45:28 -0700262 LOG(WARNING) << "Unexpected empty care map";
Tianjie Xu4d9e62d2018-05-11 10:41:44 -0700263 return false;
264 }
265
Tianjie Xu446b64b2018-09-19 15:45:28 -0700266 if (android::base::EndsWith(care_map_name, ".txt")) {
267 return ParseCareMapPlainText(file_content);
268 }
269
270 recovery_update_verifier::CareMap care_map;
Tianjie Xu4d9e62d2018-05-11 10:41:44 -0700271 if (!care_map.ParseFromString(file_content)) {
Tianjie Xu446b64b2018-09-19 15:45:28 -0700272 LOG(WARNING) << "Failed to parse " << care_map_name << " in protobuf format.";
273 return false;
Tianjie Xu4d9e62d2018-05-11 10:41:44 -0700274 }
275
276 for (const auto& partition : care_map.partitions()) {
277 if (partition.name().empty()) {
Tianjie Xu446b64b2018-09-19 15:45:28 -0700278 LOG(WARNING) << "Unexpected empty partition name.";
Tianjie Xu4d9e62d2018-05-11 10:41:44 -0700279 return false;
280 }
281 if (partition.ranges().empty()) {
Tianjie Xu446b64b2018-09-19 15:45:28 -0700282 LOG(WARNING) << "Unexpected block ranges for partition " << partition.name();
Tianjie Xu4d9e62d2018-05-11 10:41:44 -0700283 return false;
284 }
Tianjie Xu446b64b2018-09-19 15:45:28 -0700285 RangeSet ranges = RangeSet::Parse(partition.ranges());
286 if (!ranges) {
287 LOG(WARNING) << "Error parsing RangeSet string " << partition.ranges();
Tianjie Xu4d9e62d2018-05-11 10:41:44 -0700288 return false;
289 }
Tianjie Xu446b64b2018-09-19 15:45:28 -0700290
Tianjie Xu9eed65e2018-09-14 12:52:02 -0700291 // Continues to check other partitions if there is a fingerprint mismatch.
292 if (partition.id().empty() || partition.id() == "unknown") {
293 LOG(WARNING) << "Skip reading partition " << partition.name()
294 << ": property_id is not provided to get fingerprint.";
295 continue;
296 }
297
298 std::string fingerprint = property_reader_(partition.id());
299 if (fingerprint != partition.fingerprint()) {
300 LOG(WARNING) << "Skip reading partition " << partition.name() << ": fingerprint "
301 << fingerprint << " doesn't match the expected value "
302 << partition.fingerprint();
303 continue;
304 }
305
Tianjie Xu446b64b2018-09-19 15:45:28 -0700306 partition_map_.emplace(partition.name(), ranges);
307 }
308
309 if (partition_map_.empty()) {
310 LOG(WARNING) << "No partition to verify";
311 return false;
Tianjie Xu4d9e62d2018-05-11 10:41:44 -0700312 }
313
314 return true;
315}
316
Tianjie Xu9eed65e2018-09-14 12:52:02 -0700317void UpdateVerifier::set_care_map_prefix(const std::string& prefix) {
318 care_map_prefix_ = prefix;
319}
320
321void UpdateVerifier::set_property_reader(
322 const std::function<std::string(const std::string&)>& property_reader) {
323 property_reader_ = property_reader;
324}
325
Tianjie Xu3958a952017-03-01 15:31:25 -0800326static int reboot_device() {
327 if (android_reboot(ANDROID_RB_RESTART2, 0, nullptr) == -1) {
328 LOG(ERROR) << "Failed to reboot.";
329 return -1;
330 }
331 while (true) pause();
332}
333
Tao Bao83b07802017-04-26 14:30:56 -0700334int update_verifier(int argc, char** argv) {
Tao Bao7197ee02015-12-05 21:21:27 -0800335 for (int i = 1; i < argc; i++) {
Tianjie Xu7b0ad9c2016-08-05 18:00:04 -0700336 LOG(INFO) << "Started with arg " << i << ": " << argv[i];
Tao Bao7197ee02015-12-05 21:21:27 -0800337 }
338
Chris Phoenix0157c782017-01-20 11:34:00 -0800339 sp<IBootControl> module = IBootControl::getService();
Connor O'Brienad43d2d2016-11-21 12:47:33 -0800340 if (module == nullptr) {
Tianjie Xu7b0ad9c2016-08-05 18:00:04 -0700341 LOG(ERROR) << "Error getting bootctrl module.";
Tianjie Xu3958a952017-03-01 15:31:25 -0800342 return reboot_device();
Tao Bao7197ee02015-12-05 21:21:27 -0800343 }
344
Connor O'Brienad43d2d2016-11-21 12:47:33 -0800345 uint32_t current_slot = module->getCurrentSlot();
346 BoolResult is_successful = module->isSlotMarkedSuccessful(current_slot);
347 LOG(INFO) << "Booting slot " << current_slot << ": isSlotMarkedSuccessful="
348 << static_cast<int32_t>(is_successful);
Tao Bao7197ee02015-12-05 21:21:27 -0800349
Connor O'Brienad43d2d2016-11-21 12:47:33 -0800350 if (is_successful == BoolResult::FALSE) {
Tao Bao7197ee02015-12-05 21:21:27 -0800351 // The current slot has not booted successfully.
Tao Baodb57f0d2017-03-10 14:21:25 -0800352
David Zeuthen1a0929c2017-08-07 18:47:27 -0400353 bool skip_verification = false;
Tao Bao4f8d2172017-01-13 15:36:32 -0800354 std::string verity_mode = android::base::GetProperty("ro.boot.veritymode", "");
355 if (verity_mode.empty()) {
Tao Bao1cc03512018-04-18 17:10:49 -0700356 // Skip the verification if ro.boot.veritymode property is not set. This could be a result
357 // that device doesn't support dm-verity, or has disabled that.
358 LOG(WARNING) << "dm-verity not enabled; marking without verification.";
David Zeuthen1a0929c2017-08-07 18:47:27 -0400359 skip_verification = true;
Tao Bao4f8d2172017-01-13 15:36:32 -0800360 } else if (android::base::EqualsIgnoreCase(verity_mode, "eio")) {
Tianjie Xu3958a952017-03-01 15:31:25 -0800361 // We shouldn't see verity in EIO mode if the current slot hasn't booted successfully before.
362 // Continue the verification until we fail to read some blocks.
363 LOG(WARNING) << "Found dm-verity in EIO mode.";
David Zeuthen1a0929c2017-08-07 18:47:27 -0400364 } else if (android::base::EqualsIgnoreCase(verity_mode, "disabled")) {
365 LOG(WARNING) << "dm-verity in disabled mode; marking without verification.";
366 skip_verification = true;
Tao Bao4f8d2172017-01-13 15:36:32 -0800367 } else if (verity_mode != "enforcing") {
Tao Bao1cc03512018-04-18 17:10:49 -0700368 LOG(ERROR) << "Unexpected dm-verity mode: " << verity_mode << ", expecting enforcing.";
Tianjie Xu3958a952017-03-01 15:31:25 -0800369 return reboot_device();
370 }
371
David Zeuthen1a0929c2017-08-07 18:47:27 -0400372 if (!skip_verification) {
Tianjie Xu446b64b2018-09-19 15:45:28 -0700373 UpdateVerifier verifier;
374 if (!verifier.ParseCareMap()) {
375 LOG(WARNING) << "Failed to parse the care map file, skipping verification";
376 } else if (!verifier.VerifyPartitions()) {
David Zeuthen1a0929c2017-08-07 18:47:27 -0400377 LOG(ERROR) << "Failed to verify all blocks in care map file.";
378 return reboot_device();
379 }
Tianjie Xud007cf22016-02-29 16:08:06 -0800380 }
Tao Bao7197ee02015-12-05 21:21:27 -0800381
Daniel Rosenberg15f22bd2019-01-22 19:57:28 -0800382 bool supports_checkpoint = false;
383 auto sm = android::defaultServiceManager();
384 android::sp<android::IBinder> binder = sm->getService(android::String16("vold"));
385 if (binder) {
386 auto vold = android::interface_cast<android::os::IVold>(binder);
387 android::binder::Status status = vold->supportsCheckpoint(&supports_checkpoint);
388 if (!status.isOk()) {
389 LOG(ERROR) << "Failed to check if checkpoints supported. Continuing";
390 }
391 } else {
392 LOG(ERROR) << "Failed to obtain vold Binder. Continuing";
Tao Bao7197ee02015-12-05 21:21:27 -0800393 }
Daniel Rosenberg15f22bd2019-01-22 19:57:28 -0800394
395 if (!supports_checkpoint) {
396 CommandResult cr;
397 module->markBootSuccessful([&cr](CommandResult result) { cr = result; });
398 if (!cr.success) {
399 LOG(ERROR) << "Error marking booted successfully: " << cr.errMsg;
400 return reboot_device();
401 }
402 LOG(INFO) << "Marked slot " << current_slot << " as booted successfully.";
403 } else {
404 LOG(INFO) << "Deferred marking slot " << current_slot << " as booted successfully.";
405 }
Tao Bao7197ee02015-12-05 21:21:27 -0800406 }
407
Tianjie Xu7b0ad9c2016-08-05 18:00:04 -0700408 LOG(INFO) << "Leaving update_verifier.";
Tao Bao7197ee02015-12-05 21:21:27 -0800409 return 0;
410}