Tao Bao | 7197ee0 | 2015-12-05 21:21:27 -0800 | [diff] [blame] | 1 | /* |
| 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 | /* |
| 18 | * This program verifies the integrity of the partitions after an A/B OTA |
| 19 | * update. It gets invoked by init, and will only perform the verification if |
| 20 | * it's the first boot post an A/B OTA update. |
| 21 | * |
Tianjie Xu | 3958a95 | 2017-03-01 15:31:25 -0800 | [diff] [blame] | 22 | * Update_verifier relies on dm-verity to capture any corruption on the partitions |
| 23 | * being verified. And its behavior varies depending on the dm-verity mode. |
| 24 | * Upon detection of failures: |
| 25 | * enforcing mode: dm-verity reboots the device |
| 26 | * eio mode: dm-verity fails the read and update_verifier reboots the device |
| 27 | * other mode: not supported and update_verifier reboots the device |
| 28 | * |
| 29 | * After a predefined number of failing boot attempts, the bootloader should |
Tianjie Xu | d007cf2 | 2016-02-29 16:08:06 -0800 | [diff] [blame] | 30 | * mark the slot as unbootable and stops trying. Other dm-verity modes ( |
| 31 | * for example, veritymode=EIO) are not accepted and simply lead to a |
| 32 | * verification failure. |
Tao Bao | 7197ee0 | 2015-12-05 21:21:27 -0800 | [diff] [blame] | 33 | * |
| 34 | * The current slot will be marked as having booted successfully if the |
| 35 | * verifier reaches the end after the verification. |
Tao Bao | 7197ee0 | 2015-12-05 21:21:27 -0800 | [diff] [blame] | 36 | */ |
| 37 | |
Tao Bao | 83b0780 | 2017-04-26 14:30:56 -0700 | [diff] [blame] | 38 | #include "update_verifier/update_verifier.h" |
| 39 | |
Tianjie Xu | b0ac872 | 2017-01-18 18:41:53 -0800 | [diff] [blame] | 40 | #include <dirent.h> |
Tianjie Xu | d007cf2 | 2016-02-29 16:08:06 -0800 | [diff] [blame] | 41 | #include <errno.h> |
| 42 | #include <fcntl.h> |
| 43 | #include <stdio.h> |
Tao Bao | 7197ee0 | 2015-12-05 21:21:27 -0800 | [diff] [blame] | 44 | #include <string.h> |
Tianjie Xu | 3958a95 | 2017-03-01 15:31:25 -0800 | [diff] [blame] | 45 | #include <unistd.h> |
Tao Bao | 7197ee0 | 2015-12-05 21:21:27 -0800 | [diff] [blame] | 46 | |
Tianjie Xu | 8fa8f0b | 2017-04-27 11:47:35 -0700 | [diff] [blame] | 47 | #include <algorithm> |
Wei Wang | 5226f47 | 2017-08-02 10:27:31 -0700 | [diff] [blame] | 48 | #include <future> |
Tianjie Xu | d007cf2 | 2016-02-29 16:08:06 -0800 | [diff] [blame] | 49 | #include <string> |
| 50 | #include <vector> |
| 51 | |
| 52 | #include <android-base/file.h> |
Tianjie Xu | 7b0ad9c | 2016-08-05 18:00:04 -0700 | [diff] [blame] | 53 | #include <android-base/logging.h> |
Tianjie Xu | d007cf2 | 2016-02-29 16:08:06 -0800 | [diff] [blame] | 54 | #include <android-base/parseint.h> |
Tao Bao | 4f8d217 | 2017-01-13 15:36:32 -0800 | [diff] [blame] | 55 | #include <android-base/properties.h> |
Tianjie Xu | d007cf2 | 2016-02-29 16:08:06 -0800 | [diff] [blame] | 56 | #include <android-base/strings.h> |
| 57 | #include <android-base/unique_fd.h> |
Connor O'Brien | ad43d2d | 2016-11-21 12:47:33 -0800 | [diff] [blame] | 58 | #include <android/hardware/boot/1.0/IBootControl.h> |
Tianjie Xu | 3958a95 | 2017-03-01 15:31:25 -0800 | [diff] [blame] | 59 | #include <cutils/android_reboot.h> |
Connor O'Brien | ad43d2d | 2016-11-21 12:47:33 -0800 | [diff] [blame] | 60 | |
| 61 | using android::sp; |
| 62 | using android::hardware::boot::V1_0::IBootControl; |
| 63 | using android::hardware::boot::V1_0::BoolResult; |
| 64 | using android::hardware::boot::V1_0::CommandResult; |
Tao Bao | 7197ee0 | 2015-12-05 21:21:27 -0800 | [diff] [blame] | 65 | |
Tianjie Xu | b0ac872 | 2017-01-18 18:41:53 -0800 | [diff] [blame] | 66 | // Find directories in format of "/sys/block/dm-X". |
| 67 | static int dm_name_filter(const dirent* de) { |
| 68 | if (android::base::StartsWith(de->d_name, "dm-")) { |
| 69 | return 1; |
| 70 | } |
| 71 | return 0; |
| 72 | } |
| 73 | |
Tianjie Xu | 3958a95 | 2017-03-01 15:31:25 -0800 | [diff] [blame] | 74 | static bool read_blocks(const std::string& partition, const std::string& range_str) { |
Tianjie Xu | 5a176c0 | 2017-03-31 16:36:12 -0700 | [diff] [blame] | 75 | if (partition != "system" && partition != "vendor") { |
| 76 | LOG(ERROR) << "partition name must be system or vendor: " << partition; |
| 77 | return false; |
| 78 | } |
Tianjie Xu | b0ac872 | 2017-01-18 18:41:53 -0800 | [diff] [blame] | 79 | // Iterate the content of "/sys/block/dm-X/dm/name". If it matches "system" |
| 80 | // (or "vendor"), then dm-X is a dm-wrapped system/vendor partition. |
| 81 | // Afterwards, update_verifier will read every block on the care_map_file of |
| 82 | // "/dev/block/dm-X" to ensure the partition's integrity. |
Tao Bao | 83b0780 | 2017-04-26 14:30:56 -0700 | [diff] [blame] | 83 | static constexpr auto DM_PATH_PREFIX = "/sys/block/"; |
Tianjie Xu | b0ac872 | 2017-01-18 18:41:53 -0800 | [diff] [blame] | 84 | dirent** namelist; |
| 85 | int n = scandir(DM_PATH_PREFIX, &namelist, dm_name_filter, alphasort); |
| 86 | if (n == -1) { |
| 87 | PLOG(ERROR) << "Failed to scan dir " << DM_PATH_PREFIX; |
| 88 | return false; |
| 89 | } |
| 90 | if (n == 0) { |
| 91 | LOG(ERROR) << "dm block device not found for " << partition; |
| 92 | return false; |
| 93 | } |
| 94 | |
Tao Bao | 83b0780 | 2017-04-26 14:30:56 -0700 | [diff] [blame] | 95 | static constexpr auto DM_PATH_SUFFIX = "/dm/name"; |
| 96 | static constexpr auto DEV_PATH = "/dev/block/"; |
Tianjie Xu | b0ac872 | 2017-01-18 18:41:53 -0800 | [diff] [blame] | 97 | std::string dm_block_device; |
| 98 | while (n--) { |
| 99 | std::string path = DM_PATH_PREFIX + std::string(namelist[n]->d_name) + DM_PATH_SUFFIX; |
| 100 | std::string content; |
| 101 | if (!android::base::ReadFileToString(path, &content)) { |
| 102 | PLOG(WARNING) << "Failed to read " << path; |
David Zeuthen | 8ed9738 | 2017-05-08 13:41:28 -0400 | [diff] [blame] | 103 | } else { |
| 104 | std::string dm_block_name = android::base::Trim(content); |
| 105 | #ifdef BOARD_AVB_ENABLE |
| 106 | // AVB is using 'vroot' for the root block device but we're expecting 'system'. |
| 107 | if (dm_block_name == "vroot") { |
| 108 | dm_block_name = "system"; |
Tianjie Xu | b0ac872 | 2017-01-18 18:41:53 -0800 | [diff] [blame] | 109 | } |
David Zeuthen | 8ed9738 | 2017-05-08 13:41:28 -0400 | [diff] [blame] | 110 | #endif |
| 111 | if (dm_block_name == partition) { |
| 112 | dm_block_device = DEV_PATH + std::string(namelist[n]->d_name); |
| 113 | while (n--) { |
| 114 | free(namelist[n]); |
| 115 | } |
| 116 | break; |
| 117 | } |
Tianjie Xu | b0ac872 | 2017-01-18 18:41:53 -0800 | [diff] [blame] | 118 | } |
| 119 | free(namelist[n]); |
| 120 | } |
| 121 | free(namelist); |
| 122 | |
| 123 | if (dm_block_device.empty()) { |
| 124 | LOG(ERROR) << "Failed to find dm block device for " << partition; |
| 125 | return false; |
| 126 | } |
Tao Bao | 4f8d217 | 2017-01-13 15:36:32 -0800 | [diff] [blame] | 127 | |
| 128 | // For block range string, first integer 'count' equals 2 * total number of valid ranges, |
| 129 | // followed by 'count' number comma separated integers. Every two integers reprensent a |
| 130 | // block range with the first number included in range but second number not included. |
| 131 | // For example '4,64536,65343,74149,74150' represents: [64536,65343) and [74149,74150). |
| 132 | std::vector<std::string> ranges = android::base::Split(range_str, ","); |
| 133 | size_t range_count; |
| 134 | bool status = android::base::ParseUint(ranges[0], &range_count); |
| 135 | if (!status || (range_count == 0) || (range_count % 2 != 0) || |
| 136 | (range_count != ranges.size() - 1)) { |
| 137 | LOG(ERROR) << "Error in parsing range string."; |
| 138 | return false; |
| 139 | } |
Tao Bao | 6ec94c0 | 2017-10-27 23:39:45 -0700 | [diff] [blame] | 140 | range_count /= 2; |
Tao Bao | 4f8d217 | 2017-01-13 15:36:32 -0800 | [diff] [blame] | 141 | |
Wei Wang | 5226f47 | 2017-08-02 10:27:31 -0700 | [diff] [blame] | 142 | std::vector<std::future<bool>> threads; |
| 143 | size_t thread_num = std::thread::hardware_concurrency() ?: 4; |
Tao Bao | 6ec94c0 | 2017-10-27 23:39:45 -0700 | [diff] [blame] | 144 | thread_num = std::min(thread_num, range_count); |
| 145 | size_t group_range_count = (range_count + thread_num - 1) / thread_num; |
Tianjie Xu | d007cf2 | 2016-02-29 16:08:06 -0800 | [diff] [blame] | 146 | |
Wei Wang | 5226f47 | 2017-08-02 10:27:31 -0700 | [diff] [blame] | 147 | for (size_t t = 0; t < thread_num; t++) { |
| 148 | auto thread_func = [t, group_range_count, &dm_block_device, &ranges, &partition]() { |
| 149 | size_t blk_count = 0; |
| 150 | static constexpr size_t kBlockSize = 4096; |
| 151 | std::vector<uint8_t> buf(1024 * kBlockSize); |
| 152 | android::base::unique_fd fd(TEMP_FAILURE_RETRY(open(dm_block_device.c_str(), O_RDONLY))); |
| 153 | if (fd.get() == -1) { |
| 154 | PLOG(ERROR) << "Error reading " << dm_block_device << " for partition " << partition; |
Tianjie Xu | 8fa8f0b | 2017-04-27 11:47:35 -0700 | [diff] [blame] | 155 | return false; |
| 156 | } |
Wei Wang | 5226f47 | 2017-08-02 10:27:31 -0700 | [diff] [blame] | 157 | |
Tao Bao | 6ec94c0 | 2017-10-27 23:39:45 -0700 | [diff] [blame] | 158 | for (size_t i = group_range_count * 2 * t + 1; |
| 159 | i < std::min(group_range_count * 2 * (t + 1) + 1, ranges.size()); i += 2) { |
Wei Wang | 5226f47 | 2017-08-02 10:27:31 -0700 | [diff] [blame] | 160 | unsigned int range_start, range_end; |
| 161 | bool parse_status = android::base::ParseUint(ranges[i], &range_start); |
| 162 | parse_status = parse_status && android::base::ParseUint(ranges[i + 1], &range_end); |
| 163 | if (!parse_status || range_start >= range_end) { |
| 164 | LOG(ERROR) << "Invalid range pair " << ranges[i] << ", " << ranges[i + 1]; |
| 165 | return false; |
| 166 | } |
| 167 | |
| 168 | if (lseek64(fd.get(), static_cast<off64_t>(range_start) * kBlockSize, SEEK_SET) == -1) { |
| 169 | PLOG(ERROR) << "lseek to " << range_start << " failed"; |
| 170 | return false; |
| 171 | } |
| 172 | |
| 173 | size_t remain = (range_end - range_start) * kBlockSize; |
| 174 | while (remain > 0) { |
| 175 | size_t to_read = std::min(remain, 1024 * kBlockSize); |
| 176 | if (!android::base::ReadFully(fd.get(), buf.data(), to_read)) { |
| 177 | PLOG(ERROR) << "Failed to read blocks " << range_start << " to " << range_end; |
| 178 | return false; |
| 179 | } |
| 180 | remain -= to_read; |
| 181 | } |
| 182 | blk_count += (range_end - range_start); |
| 183 | } |
| 184 | LOG(INFO) << "Finished reading " << blk_count << " blocks on " << dm_block_device; |
| 185 | return true; |
| 186 | }; |
| 187 | |
| 188 | threads.emplace_back(std::async(std::launch::async, thread_func)); |
Tao Bao | 4f8d217 | 2017-01-13 15:36:32 -0800 | [diff] [blame] | 189 | } |
Tianjie Xu | d007cf2 | 2016-02-29 16:08:06 -0800 | [diff] [blame] | 190 | |
Wei Wang | 5226f47 | 2017-08-02 10:27:31 -0700 | [diff] [blame] | 191 | bool ret = true; |
| 192 | for (auto& t : threads) { |
| 193 | ret = t.get() && ret; |
| 194 | } |
| 195 | LOG(INFO) << "Finished reading blocks on " << dm_block_device << " with " << thread_num |
| 196 | << " threads."; |
| 197 | return ret; |
Tianjie Xu | d007cf2 | 2016-02-29 16:08:06 -0800 | [diff] [blame] | 198 | } |
| 199 | |
Tao Bao | 5a1dee0 | 2017-07-21 15:15:31 -0700 | [diff] [blame] | 200 | // Returns true to indicate a passing verification (or the error should be ignored); Otherwise |
| 201 | // returns false on fatal errors, where we should reject the current boot and trigger a fallback. |
| 202 | // Note that update_verifier should be backward compatible to not reject care_map.txt from old |
| 203 | // releases, which could otherwise fail to boot into the new release. For example, we've changed |
| 204 | // the care_map format between N and O. An O update_verifier would fail to work with N |
| 205 | // care_map.txt. This could be a result of sideloading an O OTA while the device having a pending N |
| 206 | // update. |
Tao Bao | 83b0780 | 2017-04-26 14:30:56 -0700 | [diff] [blame] | 207 | bool verify_image(const std::string& care_map_name) { |
Tao Bao | 5a1dee0 | 2017-07-21 15:15:31 -0700 | [diff] [blame] | 208 | android::base::unique_fd care_map_fd(TEMP_FAILURE_RETRY(open(care_map_name.c_str(), O_RDONLY))); |
| 209 | // If the device is flashed before the current boot, it may not have care_map.txt |
| 210 | // in /data/ota_package. To allow the device to continue booting in this situation, |
| 211 | // we should print a warning and skip the block verification. |
| 212 | if (care_map_fd.get() == -1) { |
| 213 | PLOG(WARNING) << "Failed to open " << care_map_name; |
Tianjie Xu | d007cf2 | 2016-02-29 16:08:06 -0800 | [diff] [blame] | 214 | return true; |
Tao Bao | 5a1dee0 | 2017-07-21 15:15:31 -0700 | [diff] [blame] | 215 | } |
| 216 | // Care map file has four lines (two lines if vendor partition is not present): |
| 217 | // First line has the block partition name (system/vendor). |
| 218 | // Second line holds all ranges of blocks to verify. |
| 219 | // The next two lines have the same format but for vendor partition. |
| 220 | std::string file_content; |
| 221 | if (!android::base::ReadFdToString(care_map_fd.get(), &file_content)) { |
| 222 | LOG(ERROR) << "Error reading care map contents to string."; |
| 223 | return false; |
| 224 | } |
| 225 | |
| 226 | std::vector<std::string> lines; |
| 227 | lines = android::base::Split(android::base::Trim(file_content), "\n"); |
| 228 | if (lines.size() != 2 && lines.size() != 4) { |
| 229 | LOG(ERROR) << "Invalid lines in care_map: found " << lines.size() |
| 230 | << " lines, expecting 2 or 4 lines."; |
| 231 | return false; |
| 232 | } |
| 233 | |
| 234 | for (size_t i = 0; i < lines.size(); i += 2) { |
| 235 | // We're seeing an N care_map.txt. Skip the verification since it's not compatible with O |
| 236 | // update_verifier (the last few metadata blocks can't be read via device mapper). |
| 237 | if (android::base::StartsWith(lines[i], "/dev/block/")) { |
| 238 | LOG(WARNING) << "Found legacy care_map.txt; skipped."; |
| 239 | return true; |
| 240 | } |
| 241 | if (!read_blocks(lines[i], lines[i+1])) { |
| 242 | return false; |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | return true; |
Tianjie Xu | d007cf2 | 2016-02-29 16:08:06 -0800 | [diff] [blame] | 247 | } |
| 248 | |
Tianjie Xu | 3958a95 | 2017-03-01 15:31:25 -0800 | [diff] [blame] | 249 | static int reboot_device() { |
| 250 | if (android_reboot(ANDROID_RB_RESTART2, 0, nullptr) == -1) { |
| 251 | LOG(ERROR) << "Failed to reboot."; |
| 252 | return -1; |
| 253 | } |
| 254 | while (true) pause(); |
| 255 | } |
| 256 | |
Tao Bao | 83b0780 | 2017-04-26 14:30:56 -0700 | [diff] [blame] | 257 | int update_verifier(int argc, char** argv) { |
Tao Bao | 7197ee0 | 2015-12-05 21:21:27 -0800 | [diff] [blame] | 258 | for (int i = 1; i < argc; i++) { |
Tianjie Xu | 7b0ad9c | 2016-08-05 18:00:04 -0700 | [diff] [blame] | 259 | LOG(INFO) << "Started with arg " << i << ": " << argv[i]; |
Tao Bao | 7197ee0 | 2015-12-05 21:21:27 -0800 | [diff] [blame] | 260 | } |
| 261 | |
Chris Phoenix | 0157c78 | 2017-01-20 11:34:00 -0800 | [diff] [blame] | 262 | sp<IBootControl> module = IBootControl::getService(); |
Connor O'Brien | ad43d2d | 2016-11-21 12:47:33 -0800 | [diff] [blame] | 263 | if (module == nullptr) { |
Tianjie Xu | 7b0ad9c | 2016-08-05 18:00:04 -0700 | [diff] [blame] | 264 | LOG(ERROR) << "Error getting bootctrl module."; |
Tianjie Xu | 3958a95 | 2017-03-01 15:31:25 -0800 | [diff] [blame] | 265 | return reboot_device(); |
Tao Bao | 7197ee0 | 2015-12-05 21:21:27 -0800 | [diff] [blame] | 266 | } |
| 267 | |
Connor O'Brien | ad43d2d | 2016-11-21 12:47:33 -0800 | [diff] [blame] | 268 | uint32_t current_slot = module->getCurrentSlot(); |
| 269 | BoolResult is_successful = module->isSlotMarkedSuccessful(current_slot); |
| 270 | LOG(INFO) << "Booting slot " << current_slot << ": isSlotMarkedSuccessful=" |
| 271 | << static_cast<int32_t>(is_successful); |
Tao Bao | 7197ee0 | 2015-12-05 21:21:27 -0800 | [diff] [blame] | 272 | |
Connor O'Brien | ad43d2d | 2016-11-21 12:47:33 -0800 | [diff] [blame] | 273 | if (is_successful == BoolResult::FALSE) { |
Tao Bao | 7197ee0 | 2015-12-05 21:21:27 -0800 | [diff] [blame] | 274 | // The current slot has not booted successfully. |
Tao Bao | db57f0d | 2017-03-10 14:21:25 -0800 | [diff] [blame] | 275 | |
David Zeuthen | 8ed9738 | 2017-05-08 13:41:28 -0400 | [diff] [blame] | 276 | #if defined(PRODUCT_SUPPORTS_VERITY) || defined(BOARD_AVB_ENABLE) |
David Zeuthen | 1a0929c | 2017-08-07 18:47:27 -0400 | [diff] [blame] | 277 | bool skip_verification = false; |
Tao Bao | 4f8d217 | 2017-01-13 15:36:32 -0800 | [diff] [blame] | 278 | std::string verity_mode = android::base::GetProperty("ro.boot.veritymode", ""); |
| 279 | if (verity_mode.empty()) { |
David Zeuthen | 1a0929c | 2017-08-07 18:47:27 -0400 | [diff] [blame] | 280 | // With AVB it's possible to disable verification entirely and |
| 281 | // in this case ro.boot.veritymode is empty. |
| 282 | #if defined(BOARD_AVB_ENABLE) |
| 283 | LOG(WARNING) << "verification has been disabled; marking without verification."; |
| 284 | skip_verification = true; |
| 285 | #else |
Tianjie Xu | d007cf2 | 2016-02-29 16:08:06 -0800 | [diff] [blame] | 286 | LOG(ERROR) << "Failed to get dm-verity mode."; |
Tianjie Xu | 3958a95 | 2017-03-01 15:31:25 -0800 | [diff] [blame] | 287 | return reboot_device(); |
David Zeuthen | 1a0929c | 2017-08-07 18:47:27 -0400 | [diff] [blame] | 288 | #endif |
Tao Bao | 4f8d217 | 2017-01-13 15:36:32 -0800 | [diff] [blame] | 289 | } else if (android::base::EqualsIgnoreCase(verity_mode, "eio")) { |
Tianjie Xu | 3958a95 | 2017-03-01 15:31:25 -0800 | [diff] [blame] | 290 | // We shouldn't see verity in EIO mode if the current slot hasn't booted successfully before. |
| 291 | // Continue the verification until we fail to read some blocks. |
| 292 | LOG(WARNING) << "Found dm-verity in EIO mode."; |
David Zeuthen | 1a0929c | 2017-08-07 18:47:27 -0400 | [diff] [blame] | 293 | } else if (android::base::EqualsIgnoreCase(verity_mode, "disabled")) { |
| 294 | LOG(WARNING) << "dm-verity in disabled mode; marking without verification."; |
| 295 | skip_verification = true; |
Tao Bao | 4f8d217 | 2017-01-13 15:36:32 -0800 | [diff] [blame] | 296 | } else if (verity_mode != "enforcing") { |
Tianjie Xu | d007cf2 | 2016-02-29 16:08:06 -0800 | [diff] [blame] | 297 | LOG(ERROR) << "Unexpected dm-verity mode : " << verity_mode << ", expecting enforcing."; |
Tianjie Xu | 3958a95 | 2017-03-01 15:31:25 -0800 | [diff] [blame] | 298 | return reboot_device(); |
| 299 | } |
| 300 | |
David Zeuthen | 1a0929c | 2017-08-07 18:47:27 -0400 | [diff] [blame] | 301 | if (!skip_verification) { |
| 302 | static constexpr auto CARE_MAP_FILE = "/data/ota_package/care_map.txt"; |
| 303 | if (!verify_image(CARE_MAP_FILE)) { |
| 304 | LOG(ERROR) << "Failed to verify all blocks in care map file."; |
| 305 | return reboot_device(); |
| 306 | } |
Tianjie Xu | d007cf2 | 2016-02-29 16:08:06 -0800 | [diff] [blame] | 307 | } |
Tao Bao | db57f0d | 2017-03-10 14:21:25 -0800 | [diff] [blame] | 308 | #else |
| 309 | LOG(WARNING) << "dm-verity not enabled; marking without verification."; |
| 310 | #endif |
Tao Bao | 7197ee0 | 2015-12-05 21:21:27 -0800 | [diff] [blame] | 311 | |
Connor O'Brien | ad43d2d | 2016-11-21 12:47:33 -0800 | [diff] [blame] | 312 | CommandResult cr; |
| 313 | module->markBootSuccessful([&cr](CommandResult result) { cr = result; }); |
| 314 | if (!cr.success) { |
| 315 | LOG(ERROR) << "Error marking booted successfully: " << cr.errMsg; |
Tianjie Xu | 3958a95 | 2017-03-01 15:31:25 -0800 | [diff] [blame] | 316 | return reboot_device(); |
Tao Bao | 7197ee0 | 2015-12-05 21:21:27 -0800 | [diff] [blame] | 317 | } |
Tianjie Xu | 7b0ad9c | 2016-08-05 18:00:04 -0700 | [diff] [blame] | 318 | LOG(INFO) << "Marked slot " << current_slot << " as booted successfully."; |
Tao Bao | 7197ee0 | 2015-12-05 21:21:27 -0800 | [diff] [blame] | 319 | } |
| 320 | |
Tianjie Xu | 7b0ad9c | 2016-08-05 18:00:04 -0700 | [diff] [blame] | 321 | LOG(INFO) << "Leaving update_verifier."; |
Tao Bao | 7197ee0 | 2015-12-05 21:21:27 -0800 | [diff] [blame] | 322 | return 0; |
| 323 | } |