^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright 2019 Google LLC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <crypto/sha.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <crypto/hash.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <linux/err.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <linux/version.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include "integrity.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) struct incfs_hash_alg *incfs_get_hash_alg(enum incfs_hash_tree_algorithm id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) static struct incfs_hash_alg sha256 = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) .name = "sha256",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) .digest_size = SHA256_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) .id = INCFS_HASH_TREE_SHA256
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) struct incfs_hash_alg *result = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) struct crypto_shash *shash;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) if (id == INCFS_HASH_TREE_SHA256) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) BUILD_BUG_ON(INCFS_MAX_HASH_SIZE < SHA256_DIGEST_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) result = &sha256;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) if (result == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) return ERR_PTR(-ENOENT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) /* pairs with cmpxchg_release() below */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) shash = smp_load_acquire(&result->shash);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) if (shash)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) return result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) shash = crypto_alloc_shash(result->name, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) if (IS_ERR(shash)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) int err = PTR_ERR(shash);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) pr_err("Can't allocate hash alg %s, error code:%d",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) result->name, err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) return ERR_PTR(err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) /* pairs with smp_load_acquire() above */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) if (cmpxchg_release(&result->shash, NULL, shash) != NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) crypto_free_shash(shash);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) return result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) struct signature_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) u32 version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) enum incfs_hash_tree_algorithm hash_algorithm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) u8 log2_blocksize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) struct mem_range salt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) struct mem_range root_hash;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) static bool read_u32(u8 **p, u8 *top, u32 *result)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) if (*p + sizeof(u32) > top)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) *result = le32_to_cpu(*(__le32 *)*p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) *p += sizeof(u32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) static bool read_u8(u8 **p, u8 *top, u8 *result)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) if (*p + sizeof(u8) > top)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) *result = *(u8 *)*p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) *p += sizeof(u8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) static bool read_mem_range(u8 **p, u8 *top, struct mem_range *range)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) u32 len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) if (!read_u32(p, top, &len) || *p + len > top)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) range->len = len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) range->data = *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) *p += len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) static int incfs_parse_signature(struct mem_range signature,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) struct signature_info *si)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) u8 *p = signature.data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) u8 *top = signature.data + signature.len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) u32 hash_section_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) if (signature.len > INCFS_MAX_SIGNATURE_SIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) if (!read_u32(&p, top, &si->version) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) si->version != INCFS_SIGNATURE_VERSION)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) if (!read_u32(&p, top, &hash_section_size) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) p + hash_section_size > top)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) top = p + hash_section_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) if (!read_u32(&p, top, &si->hash_algorithm) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) si->hash_algorithm != INCFS_HASH_TREE_SHA256)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) if (!read_u8(&p, top, &si->log2_blocksize) || si->log2_blocksize != 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) if (!read_mem_range(&p, top, &si->salt))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) if (!read_mem_range(&p, top, &si->root_hash))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) if (p != top)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) struct mtree *incfs_alloc_mtree(struct mem_range signature,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) int data_block_count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) struct signature_info si;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) struct mtree *result = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) struct incfs_hash_alg *hash_alg = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) int hash_per_block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) int lvl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) int total_blocks = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) int blocks_in_level[INCFS_MAX_MTREE_LEVELS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) int blocks = data_block_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) if (data_block_count <= 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) return ERR_PTR(-EINVAL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) error = incfs_parse_signature(signature, &si);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) return ERR_PTR(error);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) hash_alg = incfs_get_hash_alg(si.hash_algorithm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) if (IS_ERR(hash_alg))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) return ERR_PTR(PTR_ERR(hash_alg));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) if (si.root_hash.len < hash_alg->digest_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) return ERR_PTR(-EINVAL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) result = kzalloc(sizeof(*result), GFP_NOFS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) if (!result)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) return ERR_PTR(-ENOMEM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) result->alg = hash_alg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) hash_per_block = INCFS_DATA_FILE_BLOCK_SIZE / result->alg->digest_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) /* Calculating tree geometry. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) /* First pass: calculate how many blocks in each tree level. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) for (lvl = 0; blocks > 1; lvl++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) if (lvl >= INCFS_MAX_MTREE_LEVELS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) pr_err("incfs: too much data in mtree");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) blocks = (blocks + hash_per_block - 1) / hash_per_block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) blocks_in_level[lvl] = blocks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) total_blocks += blocks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) result->depth = lvl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) result->hash_tree_area_size = total_blocks * INCFS_DATA_FILE_BLOCK_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) if (result->hash_tree_area_size > INCFS_MAX_HASH_AREA_SIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) blocks = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) /* Second pass: calculate offset of each level. 0th level goes last. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) for (lvl = 0; lvl < result->depth; lvl++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) u32 suboffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) blocks += blocks_in_level[lvl];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) suboffset = (total_blocks - blocks)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) * INCFS_DATA_FILE_BLOCK_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) result->hash_level_suboffset[lvl] = suboffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) /* Root hash is stored separately from the rest of the tree. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) memcpy(result->root_hash, si.root_hash.data, hash_alg->digest_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) return result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) err:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) kfree(result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) return ERR_PTR(-E2BIG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) void incfs_free_mtree(struct mtree *tree)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) kfree(tree);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) int incfs_calc_digest(struct incfs_hash_alg *alg, struct mem_range data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) struct mem_range digest)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) SHASH_DESC_ON_STACK(desc, alg->shash);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) if (!alg || !alg->shash || !data.data || !digest.data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) if (alg->digest_size > digest.len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) desc->tfm = alg->shash;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) if (data.len < INCFS_DATA_FILE_BLOCK_SIZE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) void *buf = kzalloc(INCFS_DATA_FILE_BLOCK_SIZE, GFP_NOFS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) if (!buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) memcpy(buf, data.data, data.len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) err = crypto_shash_digest(desc, buf, INCFS_DATA_FILE_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) digest.data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) kfree(buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) return crypto_shash_digest(desc, data.data, data.len, digest.data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)