Lines Matching +full:0 +full:v

52 	struct dm_verity *v;  member
61 * The variable hash_verified is set to 0 when allocating the buffer, then
62 * it can be changed to 1 and it is never reset to 0 again.
80 aux->hash_verified = 0; in dm_bufio_alloc_callback()
86 static sector_t verity_map_sector(struct dm_verity *v, sector_t bi_sector) in verity_map_sector() argument
88 return v->data_start + dm_target_offset(v->ti, bi_sector); in verity_map_sector()
93 * (0 is the lowest level).
97 static sector_t verity_position_at_level(struct dm_verity *v, sector_t block, in verity_position_at_level() argument
100 return block >> (level * v->hash_per_block_bits); in verity_position_at_level()
103 static int verity_hash_update(struct dm_verity *v, struct ahash_request *req, in verity_hash_update() argument
127 return 0; in verity_hash_update()
134 static int verity_hash_init(struct dm_verity *v, struct ahash_request *req, in verity_hash_init() argument
139 ahash_request_set_tfm(req, v->tfm); in verity_hash_init()
147 if (unlikely(r < 0)) { in verity_hash_init()
152 if (likely(v->salt_size && (v->version >= 1))) in verity_hash_init()
153 r = verity_hash_update(v, req, v->salt, v->salt_size, wait); in verity_hash_init()
158 static int verity_hash_final(struct dm_verity *v, struct ahash_request *req, in verity_hash_final() argument
163 if (unlikely(v->salt_size && (!v->version))) { in verity_hash_final()
164 r = verity_hash_update(v, req, v->salt, v->salt_size, wait); in verity_hash_final()
166 if (r < 0) { in verity_hash_final()
172 ahash_request_set_crypt(req, NULL, digest, 0); in verity_hash_final()
178 int verity_hash(struct dm_verity *v, struct ahash_request *req, in verity_hash() argument
184 r = verity_hash_init(v, req, &wait); in verity_hash()
185 if (unlikely(r < 0)) in verity_hash()
188 r = verity_hash_update(v, req, data, len, &wait); in verity_hash()
189 if (unlikely(r < 0)) in verity_hash()
192 r = verity_hash_final(v, req, digest, &wait); in verity_hash()
198 static void verity_hash_at_level(struct dm_verity *v, sector_t block, int level, in verity_hash_at_level() argument
201 sector_t position = verity_position_at_level(v, block, level); in verity_hash_at_level()
204 *hash_block = v->hash_level_block[level] + (position >> v->hash_per_block_bits); in verity_hash_at_level()
209 idx = position & ((1 << v->hash_per_block_bits) - 1); in verity_hash_at_level()
210 if (!v->version) in verity_hash_at_level()
211 *offset = idx * v->digest_size; in verity_hash_at_level()
213 *offset = idx << (v->hash_dev_block_bits - v->hash_per_block_bits); in verity_hash_at_level()
219 static int verity_handle_err(struct dm_verity *v, enum verity_block_type type, in verity_handle_err() argument
225 struct mapped_device *md = dm_table_get_md(v->ti->table); in verity_handle_err()
228 v->hash_failed = true; in verity_handle_err()
230 if (v->corrupted_errs >= DM_VERITY_MAX_CORRUPTED_ERRS) in verity_handle_err()
233 v->corrupted_errs++; in verity_handle_err()
246 DMERR_LIMIT("%s: %s block %llu is corrupted", v->data_dev->name, in verity_handle_err()
249 if (v->corrupted_errs == DM_VERITY_MAX_CORRUPTED_ERRS) in verity_handle_err()
250 DMERR("%s: reached maximum errors", v->data_dev->name); in verity_handle_err()
258 if (v->mode == DM_VERITY_MODE_LOGGING) in verity_handle_err()
259 return 0; in verity_handle_err()
261 if (v->mode == DM_VERITY_MODE_RESTART) in verity_handle_err()
264 if (v->mode == DM_VERITY_MODE_PANIC) in verity_handle_err()
274 * On successful return, verity_io_want_digest(v, io) contains the hash value
279 * against current value of verity_io_want_digest(v, io).
281 static int verity_verify_level(struct dm_verity *v, struct dm_verity_io *io, in verity_verify_level() argument
292 verity_hash_at_level(v, block, level, &hash_block, &offset); in verity_verify_level()
295 data = dm_bufio_get(v->bufio, hash_block, &buf); in verity_verify_level()
305 data = dm_bufio_read(v->bufio, hash_block, &buf); in verity_verify_level()
318 r = verity_hash(v, verity_io_hash_req(v, io), in verity_verify_level()
319 data, 1 << v->hash_dev_block_bits, in verity_verify_level()
320 verity_io_real_digest(v, io)); in verity_verify_level()
321 if (unlikely(r < 0)) in verity_verify_level()
324 if (likely(memcmp(verity_io_real_digest(v, io), want_digest, in verity_verify_level()
325 v->digest_size) == 0)) in verity_verify_level()
336 else if (verity_fec_decode(v, io, in verity_verify_level()
338 hash_block, data, NULL) == 0) in verity_verify_level()
340 else if (verity_handle_err(v, in verity_verify_level()
349 memcpy(want_digest, data, v->digest_size); in verity_verify_level()
350 r = 0; in verity_verify_level()
361 int verity_hash_for_block(struct dm_verity *v, struct dm_verity_io *io, in verity_hash_for_block() argument
364 int r = 0, i; in verity_hash_for_block()
366 if (likely(v->levels)) { in verity_hash_for_block()
374 r = verity_verify_level(v, io, block, 0, true, digest); in verity_hash_for_block()
375 if (likely(r <= 0)) in verity_hash_for_block()
379 memcpy(digest, v->root_digest, v->digest_size); in verity_hash_for_block()
381 for (i = v->levels - 1; i >= 0; i--) { in verity_hash_for_block()
382 r = verity_verify_level(v, io, block, i, false, digest); in verity_hash_for_block()
387 if (!r && v->zero_digest) in verity_hash_for_block()
388 *is_zero = !memcmp(v->zero_digest, digest, v->digest_size); in verity_hash_for_block()
398 static int verity_for_io_block(struct dm_verity *v, struct dm_verity_io *io, in verity_for_io_block() argument
401 unsigned int todo = 1 << v->data_dev_block_bits; in verity_for_io_block()
402 struct bio *bio = dm_bio_from_per_bio_data(io, v->ti->per_io_data_size); in verity_for_io_block()
404 struct ahash_request *req = verity_io_hash_req(v, io); in verity_for_io_block()
426 if (unlikely(r < 0)) { in verity_for_io_block()
435 return 0; in verity_for_io_block()
439 * Calls function process for 1 << v->data_dev_block_bits bytes in the bio_vec
442 int verity_for_bv_block(struct dm_verity *v, struct dm_verity_io *io, in verity_for_bv_block() argument
444 int (*process)(struct dm_verity *v, in verity_for_bv_block() argument
448 unsigned todo = 1 << v->data_dev_block_bits; in verity_for_bv_block()
449 struct bio *bio = dm_bio_from_per_bio_data(io, v->ti->per_io_data_size); in verity_for_bv_block()
463 r = process(v, io, page, len); in verity_for_bv_block()
466 if (r < 0) in verity_for_bv_block()
473 return 0; in verity_for_bv_block()
476 static int verity_bv_zero(struct dm_verity *v, struct dm_verity_io *io, in verity_bv_zero() argument
479 memset(data, 0, len); in verity_bv_zero()
480 return 0; in verity_bv_zero()
486 static inline void verity_bv_skip_block(struct dm_verity *v, in verity_bv_skip_block() argument
490 struct bio *bio = dm_bio_from_per_bio_data(io, v->ti->per_io_data_size); in verity_bv_skip_block()
492 bio_advance_iter(bio, iter, 1 << v->data_dev_block_bits); in verity_bv_skip_block()
501 struct dm_verity *v = io->v; in verity_verify_io() local
508 struct bio *bio = dm_bio_from_per_bio_data(io, v->ti->per_io_data_size); in verity_verify_io()
521 for (b = 0; b < io->n_blocks; b++) { in verity_verify_io()
524 struct ahash_request *req = verity_io_hash_req(v, io); in verity_verify_io()
526 if (v->validated_blocks && in verity_verify_io()
527 likely(test_bit(cur_block, v->validated_blocks))) { in verity_verify_io()
528 verity_bv_skip_block(v, io, iter); in verity_verify_io()
532 r = verity_hash_for_block(v, io, cur_block, in verity_verify_io()
533 verity_io_want_digest(v, io), in verity_verify_io()
535 if (unlikely(r < 0)) in verity_verify_io()
543 r = verity_for_bv_block(v, io, iter, in verity_verify_io()
545 if (unlikely(r < 0)) in verity_verify_io()
551 r = verity_hash_init(v, req, &wait); in verity_verify_io()
552 if (unlikely(r < 0)) in verity_verify_io()
556 if (verity_fec_is_enabled(v)) in verity_verify_io()
559 r = verity_for_io_block(v, io, iter, &wait); in verity_verify_io()
560 if (unlikely(r < 0)) in verity_verify_io()
563 r = verity_hash_final(v, req, verity_io_real_digest(v, io), in verity_verify_io()
565 if (unlikely(r < 0)) in verity_verify_io()
568 if (likely(memcmp(verity_io_real_digest(v, io), in verity_verify_io()
569 verity_io_want_digest(v, io), v->digest_size) == 0)) { in verity_verify_io()
570 if (v->validated_blocks) in verity_verify_io()
571 set_bit(cur_block, v->validated_blocks); in verity_verify_io()
581 } else if (verity_fec_decode(v, io, DM_VERITY_BLOCK_TYPE_DATA, in verity_verify_io()
582 cur_block, NULL, &start) == 0) { in verity_verify_io()
592 if (verity_handle_err(v, DM_VERITY_BLOCK_TYPE_DATA, in verity_verify_io()
598 return 0; in verity_verify_io()
615 struct dm_verity *v = io->v; in verity_finish_io() local
616 struct bio *bio = dm_bio_from_per_bio_data(io, v->ti->per_io_data_size); in verity_finish_io()
647 queue_work(io->v->verify_wq, &io->work); in verity_tasklet()
659 (!verity_fec_is_enabled(io->v) || verity_is_system_shutting_down())) { in verity_end_io()
664 if (static_branch_unlikely(&use_tasklet_enabled) && io->v->use_tasklet) { in verity_end_io()
669 queue_work(io->v->verify_wq, &io->work); in verity_end_io()
682 struct dm_verity *v = pw->v; in verity_prefetch_io() local
685 for (i = v->levels - 2; i >= 0; i--) { in verity_prefetch_io()
688 verity_hash_at_level(v, pw->block, i, &hash_block_start, NULL); in verity_prefetch_io()
689 verity_hash_at_level(v, pw->block + pw->n_blocks - 1, i, &hash_block_end, NULL); in verity_prefetch_io()
693 cluster >>= v->data_dev_block_bits; in verity_prefetch_io()
702 if (unlikely(hash_block_end >= v->hash_blocks)) in verity_prefetch_io()
703 hash_block_end = v->hash_blocks - 1; in verity_prefetch_io()
706 dm_bufio_prefetch(v->bufio, hash_block_start, in verity_prefetch_io()
713 static void verity_submit_prefetch(struct dm_verity *v, struct dm_verity_io *io) in verity_submit_prefetch() argument
719 if (v->validated_blocks) { in verity_submit_prefetch()
720 while (n_blocks && test_bit(block, v->validated_blocks)) { in verity_submit_prefetch()
725 v->validated_blocks)) in verity_submit_prefetch()
738 pw->v = v; in verity_submit_prefetch()
741 queue_work(v->verify_wq, &pw->work); in verity_submit_prefetch()
750 struct dm_verity *v = ti->private; in verity_map() local
753 bio_set_dev(bio, v->data_dev->bdev); in verity_map()
754 bio->bi_iter.bi_sector = verity_map_sector(v, bio->bi_iter.bi_sector); in verity_map()
757 ((1 << (v->data_dev_block_bits - SECTOR_SHIFT)) - 1)) { in verity_map()
763 (v->data_dev_block_bits - SECTOR_SHIFT) > v->data_blocks) { in verity_map()
772 io->v = v; in verity_map()
774 io->block = bio->bi_iter.bi_sector >> (v->data_dev_block_bits - SECTOR_SHIFT); in verity_map()
775 io->n_blocks = bio->bi_iter.bi_size >> v->data_dev_block_bits; in verity_map()
781 verity_submit_prefetch(v, io); in verity_map()
789 * Status: V (valid) or C (corruption found)
794 struct dm_verity *v = ti->private; in verity_status() local
795 unsigned args = 0; in verity_status()
796 unsigned sz = 0; in verity_status()
801 DMEMIT("%c", v->hash_failed ? 'C' : 'V'); in verity_status()
805 v->version, in verity_status()
806 v->data_dev->name, in verity_status()
807 v->hash_dev->name, in verity_status()
808 1 << v->data_dev_block_bits, in verity_status()
809 1 << v->hash_dev_block_bits, in verity_status()
810 (unsigned long long)v->data_blocks, in verity_status()
811 (unsigned long long)v->hash_start, in verity_status()
812 v->alg_name in verity_status()
814 for (x = 0; x < v->digest_size; x++) in verity_status()
815 DMEMIT("%02x", v->root_digest[x]); in verity_status()
817 if (!v->salt_size) in verity_status()
820 for (x = 0; x < v->salt_size; x++) in verity_status()
821 DMEMIT("%02x", v->salt[x]); in verity_status()
822 if (v->mode != DM_VERITY_MODE_EIO) in verity_status()
824 if (verity_fec_is_enabled(v)) in verity_status()
826 if (v->zero_digest) in verity_status()
828 if (v->validated_blocks) in verity_status()
830 if (v->use_tasklet) in verity_status()
832 if (v->signature_key_desc) in verity_status()
837 if (v->mode != DM_VERITY_MODE_EIO) { in verity_status()
839 switch (v->mode) { in verity_status()
853 if (v->zero_digest) in verity_status()
855 if (v->validated_blocks) in verity_status()
857 if (v->use_tasklet) in verity_status()
859 sz = verity_fec_status_table(v, sz, result, maxlen); in verity_status()
860 if (v->signature_key_desc) in verity_status()
862 " %s", v->signature_key_desc); in verity_status()
867 DMEMIT(",hash_failed=%c", v->hash_failed ? 'C' : 'V'); in verity_status()
868 DMEMIT(",verity_version=%u", v->version); in verity_status()
869 DMEMIT(",data_device_name=%s", v->data_dev->name); in verity_status()
870 DMEMIT(",hash_device_name=%s", v->hash_dev->name); in verity_status()
871 DMEMIT(",verity_algorithm=%s", v->alg_name); in verity_status()
874 for (x = 0; x < v->digest_size; x++) in verity_status()
875 DMEMIT("%02x", v->root_digest[x]); in verity_status()
878 if (!v->salt_size) in verity_status()
881 for (x = 0; x < v->salt_size; x++) in verity_status()
882 DMEMIT("%02x", v->salt[x]); in verity_status()
884 DMEMIT(",ignore_zero_blocks=%c", v->zero_digest ? 'y' : 'n'); in verity_status()
885 DMEMIT(",check_at_most_once=%c", v->validated_blocks ? 'y' : 'n'); in verity_status()
886 if (v->signature_key_desc) in verity_status()
887 DMEMIT(",root_hash_sig_key_desc=%s", v->signature_key_desc); in verity_status()
889 if (v->mode != DM_VERITY_MODE_EIO) { in verity_status()
891 switch (v->mode) { in verity_status()
912 struct dm_verity *v = ti->private; in verity_prepare_ioctl() local
914 *bdev = v->data_dev->bdev; in verity_prepare_ioctl()
916 if (v->data_start || ti->len != bdev_nr_sectors(v->data_dev->bdev)) in verity_prepare_ioctl()
918 return 0; in verity_prepare_ioctl()
924 struct dm_verity *v = ti->private; in verity_iterate_devices() local
926 return fn(ti, v->data_dev, v->data_start, ti->len, data); in verity_iterate_devices()
931 struct dm_verity *v = ti->private; in verity_io_hints() local
933 if (limits->logical_block_size < 1 << v->data_dev_block_bits) in verity_io_hints()
934 limits->logical_block_size = 1 << v->data_dev_block_bits; in verity_io_hints()
936 if (limits->physical_block_size < 1 << v->data_dev_block_bits) in verity_io_hints()
937 limits->physical_block_size = 1 << v->data_dev_block_bits; in verity_io_hints()
944 struct dm_verity *v = ti->private; in verity_dtr() local
946 if (v->verify_wq) in verity_dtr()
947 destroy_workqueue(v->verify_wq); in verity_dtr()
949 if (v->bufio) in verity_dtr()
950 dm_bufio_client_destroy(v->bufio); in verity_dtr()
952 kvfree(v->validated_blocks); in verity_dtr()
953 kfree(v->salt); in verity_dtr()
954 kfree(v->root_digest); in verity_dtr()
955 kfree(v->zero_digest); in verity_dtr()
957 if (v->tfm) in verity_dtr()
958 crypto_free_ahash(v->tfm); in verity_dtr()
960 kfree(v->alg_name); in verity_dtr()
962 if (v->hash_dev) in verity_dtr()
963 dm_put_device(ti, v->hash_dev); in verity_dtr()
965 if (v->data_dev) in verity_dtr()
966 dm_put_device(ti, v->data_dev); in verity_dtr()
968 verity_fec_dtr(v); in verity_dtr()
970 kfree(v->signature_key_desc); in verity_dtr()
972 if (v->use_tasklet) in verity_dtr()
975 kfree(v); in verity_dtr()
978 static int verity_alloc_most_once(struct dm_verity *v) in verity_alloc_most_once() argument
980 struct dm_target *ti = v->ti; in verity_alloc_most_once()
983 if (v->data_blocks > INT_MAX) { in verity_alloc_most_once()
988 v->validated_blocks = kvcalloc(BITS_TO_LONGS(v->data_blocks), in verity_alloc_most_once()
991 if (!v->validated_blocks) { in verity_alloc_most_once()
996 return 0; in verity_alloc_most_once()
999 static int verity_alloc_zero_digest(struct dm_verity *v) in verity_alloc_zero_digest() argument
1005 v->zero_digest = kmalloc(v->digest_size, GFP_KERNEL); in verity_alloc_zero_digest()
1007 if (!v->zero_digest) in verity_alloc_zero_digest()
1010 req = kmalloc(v->ahash_reqsize, GFP_KERNEL); in verity_alloc_zero_digest()
1015 zero_data = kzalloc(1 << v->data_dev_block_bits, GFP_KERNEL); in verity_alloc_zero_digest()
1020 r = verity_hash(v, req, zero_data, 1 << v->data_dev_block_bits, in verity_alloc_zero_digest()
1021 v->zero_digest); in verity_alloc_zero_digest()
1037 static int verity_parse_verity_mode(struct dm_verity *v, const char *arg_name) in verity_parse_verity_mode() argument
1039 if (v->mode) in verity_parse_verity_mode()
1043 v->mode = DM_VERITY_MODE_LOGGING; in verity_parse_verity_mode()
1045 v->mode = DM_VERITY_MODE_RESTART; in verity_parse_verity_mode()
1047 v->mode = DM_VERITY_MODE_PANIC; in verity_parse_verity_mode()
1049 return 0; in verity_parse_verity_mode()
1052 static int verity_parse_opt_args(struct dm_arg_set *as, struct dm_verity *v, in verity_parse_opt_args() argument
1056 int r = 0; in verity_parse_opt_args()
1058 struct dm_target *ti = v->ti; in verity_parse_opt_args()
1062 {0, DM_VERITY_OPTS_MAX, "Invalid number of feature args"}, in verity_parse_opt_args()
1070 return 0; in verity_parse_opt_args()
1079 r = verity_parse_verity_mode(v, arg_name); in verity_parse_opt_args()
1089 r = verity_alloc_zero_digest(v); in verity_parse_opt_args()
1099 r = verity_alloc_most_once(v); in verity_parse_opt_args()
1105 v->use_tasklet = true; in verity_parse_opt_args()
1112 r = verity_fec_parse_opt_args(as, v, &argc, arg_name); in verity_parse_opt_args()
1120 r = verity_verify_sig_parse_opt_args(as, v, in verity_parse_opt_args()
1148 * Vsn 0 is compatible with original Chromium OS releases.
1161 struct dm_verity *v; in verity_ctr() local
1162 struct dm_verity_sig_opts verify_args = {0}; in verity_ctr()
1173 v = kzalloc(sizeof(struct dm_verity), GFP_KERNEL); in verity_ctr()
1174 if (!v) { in verity_ctr()
1178 ti->private = v; in verity_ctr()
1179 v->ti = ti; in verity_ctr()
1181 r = verity_fec_ctr_alloc(v); in verity_ctr()
1201 r = verity_parse_opt_args(&as, v, &verify_args, true); in verity_ctr()
1202 if (r < 0) in verity_ctr()
1206 if (sscanf(argv[0], "%u%c", &num, &dummy) != 1 || in verity_ctr()
1212 v->version = num; in verity_ctr()
1214 r = dm_get_device(ti, argv[1], FMODE_READ, &v->data_dev); in verity_ctr()
1220 r = dm_get_device(ti, argv[2], FMODE_READ, &v->hash_dev); in verity_ctr()
1228 num < bdev_logical_block_size(v->data_dev->bdev) || in verity_ctr()
1234 v->data_dev_block_bits = __ffs(num); in verity_ctr()
1238 num < bdev_logical_block_size(v->hash_dev->bdev) || in verity_ctr()
1244 v->hash_dev_block_bits = __ffs(num); in verity_ctr()
1247 (sector_t)(num_ll << (v->data_dev_block_bits - SECTOR_SHIFT)) in verity_ctr()
1248 >> (v->data_dev_block_bits - SECTOR_SHIFT) != num_ll) { in verity_ctr()
1253 v->data_blocks = num_ll; in verity_ctr()
1255 if (ti->len > (v->data_blocks << (v->data_dev_block_bits - SECTOR_SHIFT))) { in verity_ctr()
1262 (sector_t)(num_ll << (v->hash_dev_block_bits - SECTOR_SHIFT)) in verity_ctr()
1263 >> (v->hash_dev_block_bits - SECTOR_SHIFT) != num_ll) { in verity_ctr()
1268 v->hash_start = num_ll; in verity_ctr()
1270 v->alg_name = kstrdup(argv[7], GFP_KERNEL); in verity_ctr()
1271 if (!v->alg_name) { in verity_ctr()
1277 v->tfm = crypto_alloc_ahash(v->alg_name, 0, in verity_ctr()
1278 v->use_tasklet ? CRYPTO_ALG_ASYNC : 0); in verity_ctr()
1279 if (IS_ERR(v->tfm)) { in verity_ctr()
1281 r = PTR_ERR(v->tfm); in verity_ctr()
1282 v->tfm = NULL; in verity_ctr()
1291 DMINFO("%s using implementation \"%s\"", v->alg_name, in verity_ctr()
1292 crypto_hash_alg_common(v->tfm)->base.cra_driver_name); in verity_ctr()
1294 v->digest_size = crypto_ahash_digestsize(v->tfm); in verity_ctr()
1295 if ((1 << v->hash_dev_block_bits) < v->digest_size * 2) { in verity_ctr()
1300 v->ahash_reqsize = sizeof(struct ahash_request) + in verity_ctr()
1301 crypto_ahash_reqsize(v->tfm); in verity_ctr()
1303 v->root_digest = kmalloc(v->digest_size, GFP_KERNEL); in verity_ctr()
1304 if (!v->root_digest) { in verity_ctr()
1309 if (strlen(argv[8]) != v->digest_size * 2 || in verity_ctr()
1310 hex2bin(v->root_digest, argv[8], v->digest_size)) { in verity_ctr()
1318 v->salt_size = strlen(argv[9]) / 2; in verity_ctr()
1319 v->salt = kmalloc(v->salt_size, GFP_KERNEL); in verity_ctr()
1320 if (!v->salt) { in verity_ctr()
1325 if (strlen(argv[9]) != v->salt_size * 2 || in verity_ctr()
1326 hex2bin(v->salt, argv[9], v->salt_size)) { in verity_ctr()
1340 r = verity_parse_opt_args(&as, v, &verify_args, false); in verity_ctr()
1341 if (r < 0) in verity_ctr()
1350 if (r < 0) { in verity_ctr()
1354 v->hash_per_block_bits = in verity_ctr()
1355 __fls((1 << v->hash_dev_block_bits) / v->digest_size); in verity_ctr()
1357 v->levels = 0; in verity_ctr()
1358 if (v->data_blocks) in verity_ctr()
1359 while (v->hash_per_block_bits * v->levels < 64 && in verity_ctr()
1360 (unsigned long long)(v->data_blocks - 1) >> in verity_ctr()
1361 (v->hash_per_block_bits * v->levels)) in verity_ctr()
1362 v->levels++; in verity_ctr()
1364 if (v->levels > DM_VERITY_MAX_LEVELS) { in verity_ctr()
1370 hash_position = v->hash_start; in verity_ctr()
1371 for (i = v->levels - 1; i >= 0; i--) { in verity_ctr()
1373 v->hash_level_block[i] = hash_position; in verity_ctr()
1374 s = (v->data_blocks + ((sector_t)1 << ((i + 1) * v->hash_per_block_bits)) - 1) in verity_ctr()
1375 >> ((i + 1) * v->hash_per_block_bits); in verity_ctr()
1383 v->hash_blocks = hash_position; in verity_ctr()
1385 v->bufio = dm_bufio_client_create(v->hash_dev->bdev, in verity_ctr()
1386 1 << v->hash_dev_block_bits, 1, sizeof(struct buffer_aux), in verity_ctr()
1388 v->use_tasklet ? DM_BUFIO_CLIENT_NO_SLEEP : 0); in verity_ctr()
1389 if (IS_ERR(v->bufio)) { in verity_ctr()
1391 r = PTR_ERR(v->bufio); in verity_ctr()
1392 v->bufio = NULL; in verity_ctr()
1396 if (dm_bufio_get_device_size(v->bufio) < v->hash_blocks) { in verity_ctr()
1414 v->verify_wq = alloc_workqueue("kverityd", wq_flags, num_online_cpus()); in verity_ctr()
1415 if (!v->verify_wq) { in verity_ctr()
1422 v->ahash_reqsize + v->digest_size * 2; in verity_ctr()
1424 r = verity_fec_ctr(v); in verity_ctr()
1433 return 0; in verity_ctr()
1459 struct dm_verity *v = ti->private; in dm_verity_get_mode() local
1464 return v->mode; in dm_verity_get_mode()
1475 struct dm_verity *v = ti->private; in dm_verity_get_root_digest() local
1480 *root_digest = kmemdup(v->root_digest, v->digest_size, GFP_KERNEL); in dm_verity_get_root_digest()
1484 *digest_size = v->digest_size; in dm_verity_get_root_digest()
1486 return 0; in dm_verity_get_root_digest()
1492 .version = {1, 9, 0},
1508 if (r < 0) in dm_verity_init()