^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * algif_hash: User-space interface for hash algorithms
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * This file provides the user-space API for hash algorithms.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Copyright (c) 2010 Herbert Xu <herbert@gondor.apana.org.au>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <crypto/hash.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <crypto/if_alg.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/mm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/net.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <net/sock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) struct hash_ctx {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) struct af_alg_sgl sgl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) u8 *result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) struct crypto_wait wait;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) unsigned int len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) bool more;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) struct ahash_request req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) static int hash_alloc_result(struct sock *sk, struct hash_ctx *ctx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) unsigned ds;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) if (ctx->result)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) ds = crypto_ahash_digestsize(crypto_ahash_reqtfm(&ctx->req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) ctx->result = sock_kmalloc(sk, ds, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) if (!ctx->result)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) memset(ctx->result, 0, ds);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) static void hash_free_result(struct sock *sk, struct hash_ctx *ctx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) unsigned ds;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) if (!ctx->result)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) ds = crypto_ahash_digestsize(crypto_ahash_reqtfm(&ctx->req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) sock_kzfree_s(sk, ctx->result, ds);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) ctx->result = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) static int hash_sendmsg(struct socket *sock, struct msghdr *msg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) size_t ignored)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) int limit = ALG_MAX_PAGES * PAGE_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) struct sock *sk = sock->sk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) struct alg_sock *ask = alg_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) struct hash_ctx *ctx = ask->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) long copied = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) if (limit > sk->sk_sndbuf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) limit = sk->sk_sndbuf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) lock_sock(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) if (!ctx->more) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) if ((msg->msg_flags & MSG_MORE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) hash_free_result(sk, ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) err = crypto_wait_req(crypto_ahash_init(&ctx->req), &ctx->wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) ctx->more = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) while (msg_data_left(msg)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) int len = msg_data_left(msg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) if (len > limit)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) len = limit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) len = af_alg_make_sg(&ctx->sgl, &msg->msg_iter, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) if (len < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) err = copied ? 0 : len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) ahash_request_set_crypt(&ctx->req, ctx->sgl.sg, NULL, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) err = crypto_wait_req(crypto_ahash_update(&ctx->req),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) &ctx->wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) af_alg_free_sg(&ctx->sgl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) copied += len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) iov_iter_advance(&msg->msg_iter, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) ctx->more = msg->msg_flags & MSG_MORE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) if (!ctx->more) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) err = hash_alloc_result(sk, ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) ahash_request_set_crypt(&ctx->req, NULL, ctx->result, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) err = crypto_wait_req(crypto_ahash_final(&ctx->req),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) &ctx->wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) release_sock(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) return err ?: copied;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) static ssize_t hash_sendpage(struct socket *sock, struct page *page,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) int offset, size_t size, int flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) struct sock *sk = sock->sk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) struct alg_sock *ask = alg_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) struct hash_ctx *ctx = ask->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) if (flags & MSG_SENDPAGE_NOTLAST)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) flags |= MSG_MORE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) lock_sock(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) sg_init_table(ctx->sgl.sg, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) sg_set_page(ctx->sgl.sg, page, size, offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) if (!(flags & MSG_MORE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) err = hash_alloc_result(sk, ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) } else if (!ctx->more)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) hash_free_result(sk, ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) ahash_request_set_crypt(&ctx->req, ctx->sgl.sg, ctx->result, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) if (!(flags & MSG_MORE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) if (ctx->more)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) err = crypto_ahash_finup(&ctx->req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) err = crypto_ahash_digest(&ctx->req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) if (!ctx->more) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) err = crypto_ahash_init(&ctx->req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) err = crypto_wait_req(err, &ctx->wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) err = crypto_ahash_update(&ctx->req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) err = crypto_wait_req(err, &ctx->wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) ctx->more = flags & MSG_MORE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) release_sock(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) return err ?: size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) static int hash_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) int flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) struct sock *sk = sock->sk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) struct alg_sock *ask = alg_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) struct hash_ctx *ctx = ask->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) unsigned ds = crypto_ahash_digestsize(crypto_ahash_reqtfm(&ctx->req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) bool result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) if (len > ds)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) len = ds;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) else if (len < ds)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) msg->msg_flags |= MSG_TRUNC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) lock_sock(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) result = ctx->result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) err = hash_alloc_result(sk, ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) ahash_request_set_crypt(&ctx->req, NULL, ctx->result, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) if (!result && !ctx->more) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) err = crypto_wait_req(crypto_ahash_init(&ctx->req),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) &ctx->wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) if (!result || ctx->more) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) ctx->more = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) err = crypto_wait_req(crypto_ahash_final(&ctx->req),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) &ctx->wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) err = memcpy_to_msg(msg, ctx->result, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) hash_free_result(sk, ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) release_sock(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) return err ?: len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) static int hash_accept(struct socket *sock, struct socket *newsock, int flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) bool kern)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) struct sock *sk = sock->sk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) struct alg_sock *ask = alg_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) struct hash_ctx *ctx = ask->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) struct ahash_request *req = &ctx->req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) char state[HASH_MAX_STATESIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) struct sock *sk2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) struct alg_sock *ask2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) struct hash_ctx *ctx2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) bool more;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) lock_sock(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) more = ctx->more;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) err = more ? crypto_ahash_export(req, state) : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) release_sock(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) err = af_alg_accept(ask->parent, newsock, kern);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) sk2 = newsock->sk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) ask2 = alg_sk(sk2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) ctx2 = ask2->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) ctx2->more = more;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) if (!more)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) err = crypto_ahash_import(&ctx2->req, state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) sock_orphan(sk2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) sock_put(sk2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) static struct proto_ops algif_hash_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) .family = PF_ALG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) .connect = sock_no_connect,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) .socketpair = sock_no_socketpair,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) .getname = sock_no_getname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) .ioctl = sock_no_ioctl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) .listen = sock_no_listen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) .shutdown = sock_no_shutdown,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) .mmap = sock_no_mmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) .bind = sock_no_bind,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) .release = af_alg_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) .sendmsg = hash_sendmsg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) .sendpage = hash_sendpage,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) .recvmsg = hash_recvmsg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) .accept = hash_accept,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) static int hash_check_key(struct socket *sock)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) int err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) struct sock *psk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) struct alg_sock *pask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) struct crypto_ahash *tfm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) struct sock *sk = sock->sk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) struct alg_sock *ask = alg_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) lock_sock(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) if (!atomic_read(&ask->nokey_refcnt))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) goto unlock_child;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) psk = ask->parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) pask = alg_sk(ask->parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) tfm = pask->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) err = -ENOKEY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) lock_sock_nested(psk, SINGLE_DEPTH_NESTING);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) if (crypto_ahash_get_flags(tfm) & CRYPTO_TFM_NEED_KEY)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) atomic_dec(&pask->nokey_refcnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) atomic_set(&ask->nokey_refcnt, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) release_sock(psk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) unlock_child:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) release_sock(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) static int hash_sendmsg_nokey(struct socket *sock, struct msghdr *msg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) size_t size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) err = hash_check_key(sock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) return hash_sendmsg(sock, msg, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) static ssize_t hash_sendpage_nokey(struct socket *sock, struct page *page,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) int offset, size_t size, int flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) err = hash_check_key(sock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) return hash_sendpage(sock, page, offset, size, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) static int hash_recvmsg_nokey(struct socket *sock, struct msghdr *msg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) size_t ignored, int flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) err = hash_check_key(sock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) return hash_recvmsg(sock, msg, ignored, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) static int hash_accept_nokey(struct socket *sock, struct socket *newsock,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) int flags, bool kern)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) err = hash_check_key(sock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) return hash_accept(sock, newsock, flags, kern);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) static struct proto_ops algif_hash_ops_nokey = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) .family = PF_ALG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) .connect = sock_no_connect,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) .socketpair = sock_no_socketpair,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) .getname = sock_no_getname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) .ioctl = sock_no_ioctl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) .listen = sock_no_listen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) .shutdown = sock_no_shutdown,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) .mmap = sock_no_mmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) .bind = sock_no_bind,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) .release = af_alg_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) .sendmsg = hash_sendmsg_nokey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) .sendpage = hash_sendpage_nokey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) .recvmsg = hash_recvmsg_nokey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) .accept = hash_accept_nokey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) static void *hash_bind(const char *name, u32 type, u32 mask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) return crypto_alloc_ahash(name, type, mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) static void hash_release(void *private)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) crypto_free_ahash(private);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) static int hash_setkey(void *private, const u8 *key, unsigned int keylen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) return crypto_ahash_setkey(private, key, keylen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) static void hash_sock_destruct(struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) struct alg_sock *ask = alg_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) struct hash_ctx *ctx = ask->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) hash_free_result(sk, ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) sock_kfree_s(sk, ctx, ctx->len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) af_alg_release_parent(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) static int hash_accept_parent_nokey(void *private, struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) struct crypto_ahash *tfm = private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) struct alg_sock *ask = alg_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) struct hash_ctx *ctx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) unsigned int len = sizeof(*ctx) + crypto_ahash_reqsize(tfm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) ctx = sock_kmalloc(sk, len, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) if (!ctx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) ctx->result = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) ctx->len = len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) ctx->more = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) crypto_init_wait(&ctx->wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) ask->private = ctx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) ahash_request_set_tfm(&ctx->req, tfm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) ahash_request_set_callback(&ctx->req, CRYPTO_TFM_REQ_MAY_BACKLOG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) crypto_req_done, &ctx->wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) sk->sk_destruct = hash_sock_destruct;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) static int hash_accept_parent(void *private, struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) struct crypto_ahash *tfm = private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) if (crypto_ahash_get_flags(tfm) & CRYPTO_TFM_NEED_KEY)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) return -ENOKEY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) return hash_accept_parent_nokey(private, sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) static const struct af_alg_type algif_type_hash = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) .bind = hash_bind,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) .release = hash_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) .setkey = hash_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) .accept = hash_accept_parent,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) .accept_nokey = hash_accept_parent_nokey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) .ops = &algif_hash_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) .ops_nokey = &algif_hash_ops_nokey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) .name = "hash",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) .owner = THIS_MODULE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) static int __init algif_hash_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) return af_alg_register_type(&algif_type_hash);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) static void __exit algif_hash_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) int err = af_alg_unregister_type(&algif_type_hash);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) BUG_ON(err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) module_init(algif_hash_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) module_exit(algif_hash_exit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) MODULE_LICENSE("GPL");