summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSami Tolvanen <samitolvanen@google.com>2015-12-10 20:12:49 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2015-12-10 20:12:49 +0000
commit0d1214c68ea95543468b09f7ae27bd65c8c8d7c0 (patch)
treec49b4b1278e194719e444a3327cea4d16013237e
parent59e5c25919e2348ef6dc01b94c9bafbfc8786633 (diff)
parent90f52df257ab020934558a811bad2ba0bae33c5a (diff)
downloadcore-0d1214c68ea95543468b09f7ae27bd65c8c8d7c0.tar.gz
core-0d1214c68ea95543468b09f7ae27bd65c8c8d7c0.tar.bz2
core-0d1214c68ea95543468b09f7ae27bd65c8c8d7c0.zip
Merge "Set up dm-verity in EIO mode instead of logging mode"
-rw-r--r--fs_mgr/fs_mgr_verity.cpp34
-rw-r--r--init/builtins.cpp2
2 files changed, 9 insertions, 27 deletions
diff --git a/fs_mgr/fs_mgr_verity.cpp b/fs_mgr/fs_mgr_verity.cpp
index 928d56c42..13d348571 100644
--- a/fs_mgr/fs_mgr_verity.cpp
+++ b/fs_mgr/fs_mgr_verity.cpp
@@ -695,31 +695,27 @@ static int load_verity_state(struct fstab_rec *fstab, int *mode)
int match = 0;
off64_t offset = 0;
+ /* unless otherwise specified, use EIO mode */
+ *mode = VERITY_MODE_EIO;
+
/* use the kernel parameter if set */
property_get("ro.boot.veritymode", propbuf, "");
if (*propbuf != '\0') {
if (!strcmp(propbuf, "enforcing")) {
*mode = VERITY_MODE_DEFAULT;
- return 0;
- } else if (!strcmp(propbuf, "logging")) {
- *mode = VERITY_MODE_LOGGING;
- return 0;
- } else {
- INFO("Unknown value %s for veritymode; ignoring", propbuf);
}
+ return 0;
}
if (get_verity_state_offset(fstab, &offset) < 0) {
/* fall back to stateless behavior */
- *mode = VERITY_MODE_EIO;
return 0;
}
if (was_verity_restart()) {
/* device was restarted after dm-verity detected a corrupted
- * block, so switch to logging mode */
- *mode = VERITY_MODE_LOGGING;
+ * block, so use EIO mode */
return write_verity_state(fstab->verity_loc, offset, *mode);
}
@@ -784,7 +780,6 @@ out:
int fs_mgr_update_verity_state(fs_mgr_verity_state_callback callback)
{
alignas(dm_ioctl) char buffer[DM_BUF_SIZE];
- bool use_state = true;
char fstab_filename[PROPERTY_VALUE_MAX + sizeof(FSTAB_PREFIX)];
char *mount_point;
char propbuf[PROPERTY_VALUE_MAX];
@@ -793,15 +788,11 @@ int fs_mgr_update_verity_state(fs_mgr_verity_state_callback callback)
int i;
int mode;
int rc = -1;
- off64_t offset = 0;
struct dm_ioctl *io = (struct dm_ioctl *) buffer;
struct fstab *fstab = NULL;
- /* check if we need to store the state */
- property_get("ro.boot.veritymode", propbuf, "");
-
- if (*propbuf != '\0') {
- use_state = false; /* state is kept by the bootloader */
+ if (!callback) {
+ return -1;
}
if (fs_mgr_load_verity_state(&mode) == -1) {
@@ -841,16 +832,7 @@ int fs_mgr_update_verity_state(fs_mgr_verity_state_callback callback)
status = &buffer[io->data_start + sizeof(struct dm_target_spec)];
- if (use_state && *status == 'C') {
- if (write_verity_state(fstab->recs[i].verity_loc, offset,
- VERITY_MODE_LOGGING) < 0) {
- continue;
- }
- }
-
- if (callback) {
- callback(&fstab->recs[i], mount_point, mode, *status);
- }
+ callback(&fstab->recs[i], mount_point, mode, *status);
}
rc = 0;
diff --git a/init/builtins.cpp b/init/builtins.cpp
index 58dbce1eb..10f9d8171 100644
--- a/init/builtins.cpp
+++ b/init/builtins.cpp
@@ -642,7 +642,7 @@ static int do_sysclktz(const std::vector<std::string>& args) {
static int do_verity_load_state(const std::vector<std::string>& args) {
int mode = -1;
int rc = fs_mgr_load_verity_state(&mode);
- if (rc == 0 && mode == VERITY_MODE_LOGGING) {
+ if (rc == 0 && mode != VERITY_MODE_DEFAULT) {
ActionManager::GetInstance().QueueEventTrigger("verity-logging");
}
return rc;