OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 The Chromium OS Authors <chromium-os-dev@chromium.org> | 2 * Copyright (C) 2010 The Chromium OS Authors <chromium-os-dev@chromium.org> |
3 * | 3 * |
4 * Device-Mapper block hash tree interface. | 4 * Device-Mapper block hash tree interface. |
5 * See Documentation/device-mapper/dm-bht.txt for details. | 5 * See Documentation/device-mapper/dm-bht.txt for details. |
6 * | 6 * |
7 * This file is released under the GPL. | 7 * This file is released under the GPL. |
8 */ | 8 */ |
9 | 9 |
10 #include <asm/atomic.h> | 10 #include <asm/atomic.h> |
(...skipping 1095 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1106 /* TODO(wad) do we really need this? */ | 1106 /* TODO(wad) do we really need this? */ |
1107 if (digest_len != bht->digest_size) { | 1107 if (digest_len != bht->digest_size) { |
1108 DMERR("invalid digest_len passed to verify_block"); | 1108 DMERR("invalid digest_len passed to verify_block"); |
1109 return -EINVAL; | 1109 return -EINVAL; |
1110 } | 1110 } |
1111 | 1111 |
1112 /* Make sure that the root has been verified */ | 1112 /* Make sure that the root has been verified */ |
1113 if (atomic_read(&bht->root_state) != DM_BHT_ENTRY_VERIFIED) { | 1113 if (atomic_read(&bht->root_state) != DM_BHT_ENTRY_VERIFIED) { |
1114 unverified = dm_bht_verify_root(bht, dm_bht_compare_hash); | 1114 unverified = dm_bht_verify_root(bht, dm_bht_compare_hash); |
1115 if (unverified) { | 1115 if (unverified) { |
1116 » » » DMCRIT("Failed to verify root: %d", unverified); | 1116 » » » DMERR_LIMIT("Failed to verify root: %d", unverified); |
1117 return unverified; | 1117 return unverified; |
1118 } | 1118 } |
1119 } | 1119 } |
1120 | 1120 |
1121 /* Now check that the digest supplied matches the leaf hash */ | 1121 /* Now check that the digest supplied matches the leaf hash */ |
1122 unverified = dm_bht_check_block(bht, block_index, digest, &entry_state); | 1122 unverified = dm_bht_check_block(bht, block_index, digest, &entry_state); |
1123 if (unverified) { | 1123 if (unverified) { |
1124 » » DMCRIT("Block check failed for %u: %d", block_index, | 1124 » » DMERR_LIMIT("Block check failed for %u: %d", block_index, |
1125 » » unverified); | 1125 » » » » unverified); |
1126 return unverified; | 1126 return unverified; |
1127 } | 1127 } |
1128 | 1128 |
1129 /* If the entry which contains the block hash is marked verified, then | 1129 /* If the entry which contains the block hash is marked verified, then |
1130 * it means that its hash has been check with the parent. In addition, | 1130 * it means that its hash has been check with the parent. In addition, |
1131 * since that is only possible via verify_path, it transitively means | 1131 * since that is only possible via verify_path, it transitively means |
1132 * it is verified to the root of the tree. If the depth is 1, then it | 1132 * it is verified to the root of the tree. If the depth is 1, then it |
1133 * means the entry was verified during root verification. | 1133 * means the entry was verified during root verification. |
1134 */ | 1134 */ |
1135 if (entry_state == DM_BHT_ENTRY_VERIFIED || bht->depth == 1) | 1135 if (entry_state == DM_BHT_ENTRY_VERIFIED || bht->depth == 1) |
1136 return unverified; | 1136 return unverified; |
1137 | 1137 |
1138 /* Now check levels in between */ | 1138 /* Now check levels in between */ |
1139 unverified = dm_bht_verify_path(bht, | 1139 unverified = dm_bht_verify_path(bht, |
1140 block_index, | 1140 block_index, |
1141 dm_bht_compare_hash); | 1141 dm_bht_compare_hash); |
1142 if (unverified) | 1142 if (unverified) |
1143 » » DMERR("Failed to verify intermediary nodes for block: %u (%d)", | 1143 » » DMERR_LIMIT("Failed to verify intermediary nodes for block: %u (
%d)", |
1144 block_index, unverified); | 1144 block_index, unverified); |
1145 return unverified; | 1145 return unverified; |
1146 } | 1146 } |
1147 EXPORT_SYMBOL(dm_bht_verify_block); | 1147 EXPORT_SYMBOL(dm_bht_verify_block); |
1148 | 1148 |
1149 /** | 1149 /** |
1150 * dm_bht_destroy - cleans up all memory used by @bht | 1150 * dm_bht_destroy - cleans up all memory used by @bht |
1151 * @bht: pointer to a dm_bht_create()d bht | 1151 * @bht: pointer to a dm_bht_create()d bht |
1152 * | 1152 * |
1153 * Returns 0 on success. Does not free @bht itself. | 1153 * Returns 0 on success. Does not free @bht itself. |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1302 DMERR("no root digest exists to export"); | 1302 DMERR("no root digest exists to export"); |
1303 if (available > 0) | 1303 if (available > 0) |
1304 *hexdigest = 0; | 1304 *hexdigest = 0; |
1305 return -1; | 1305 return -1; |
1306 } | 1306 } |
1307 dm_bht_bin_to_hex(bht->root_digest, hexdigest, bht->digest_size); | 1307 dm_bht_bin_to_hex(bht->root_digest, hexdigest, bht->digest_size); |
1308 return 0; | 1308 return 0; |
1309 } | 1309 } |
1310 EXPORT_SYMBOL(dm_bht_root_hexdigest); | 1310 EXPORT_SYMBOL(dm_bht_root_hexdigest); |
1311 | 1311 |
OLD | NEW |