diff options
author | Sami Tolvanen <samitolvanen@google.com> | 2015-12-10 00:04:10 +0000 |
---|---|---|
committer | Sami Tolvanen <samitolvanen@google.com> | 2015-12-10 01:01:29 +0000 |
commit | ff980d22d1c322173bed6289fd9448d8b5e58144 (patch) | |
tree | 69326065d9b9da003a0ccb55e070c97cbda08ee9 /fs_mgr | |
parent | 9729392ffa40ed37aab7fd535c6644d20279bbf0 (diff) | |
download | system_core-ff980d22d1c322173bed6289fd9448d8b5e58144.tar.gz system_core-ff980d22d1c322173bed6289fd9448d8b5e58144.tar.bz2 system_core-ff980d22d1c322173bed6289fd9448d8b5e58144.zip |
fs_mgr: support upstream dm-verity without error correction
Set up dm-verity even if kernel configuration doesn't have
CONFIG_DM_VERITY_FEC set. Fall back to the always safe EIO
mode if dm-verity doesn't support feature arguments.
Bug: 21893453
Change-Id: I4812bd74801c0abc8da479230f48b752858f9cd8
Diffstat (limited to 'fs_mgr')
-rw-r--r-- | fs_mgr/fs_mgr_verity.cpp | 42 |
1 files changed, 36 insertions, 6 deletions
diff --git a/fs_mgr/fs_mgr_verity.cpp b/fs_mgr/fs_mgr_verity.cpp index 928d56c42..32f5a5ffb 100644 --- a/fs_mgr/fs_mgr_verity.cpp +++ b/fs_mgr/fs_mgr_verity.cpp @@ -254,7 +254,7 @@ static bool format_verity_table(char *buf, const size_t bufsize, res = snprintf(buf, bufsize, "%s 2 " VERITY_TABLE_OPT_IGNZERO " %s", params->table, mode_flag); } else { - res = strlcpy(buf, params->table, bufsize); + res = snprintf(buf, bufsize, "%s 1 " VERITY_TABLE_OPT_IGNZERO, params->table); } if (res < 0 || (size_t)res >= bufsize) { @@ -962,13 +962,43 @@ int fs_mgr_setup_verity(struct fstab_rec *fstab) // load the verity mapping table if (load_verity_table(io, mount_point, verity.data_size, fd, ¶ms, - format_verity_table) < 0 && - // try the legacy format for backwards compatibility - load_verity_table(io, mount_point, verity.data_size, fd, ¶ms, - format_legacy_verity_table) < 0) { - goto out; + format_verity_table) == 0) { + goto loaded; } + if (params.ecc.valid) { + // kernel may not support error correction, try without + INFO("Disabling error correction for %s\n", mount_point); + params.ecc.valid = false; + + if (load_verity_table(io, mount_point, verity.data_size, fd, ¶ms, + format_verity_table) == 0) { + goto loaded; + } + } + + // try the legacy format for backwards compatibility + if (load_verity_table(io, mount_point, verity.data_size, fd, ¶ms, + format_legacy_verity_table) == 0) { + goto loaded; + } + + if (params.mode != VERITY_MODE_EIO) { + // as a last resort, EIO mode should always be supported + INFO("Falling back to EIO mode for %s\n", mount_point); + params.mode = VERITY_MODE_EIO; + + if (load_verity_table(io, mount_point, verity.data_size, fd, ¶ms, + format_legacy_verity_table) == 0) { + goto loaded; + } + } + + ERROR("Failed to load verity table for %s\n", mount_point); + goto out; + +loaded: + // activate the device if (resume_verity_table(io, mount_point, fd) < 0) { goto out; |