hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/crypto/algif_aead.c
....@@ -1,14 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * algif_aead: User-space interface for AEAD algorithms
34 *
45 * Copyright (C) 2014, Stephan Mueller <smueller@chronox.de>
56 *
67 * This file provides the user-space API for AEAD ciphers.
7
- *
8
- * This program is free software; you can redistribute it and/or modify it
9
- * under the terms of the GNU General Public License as published by the Free
10
- * Software Foundation; either version 2 of the License, or (at your option)
11
- * any later version.
128 *
139 * The following concept of the memory management is used:
1410 *
....@@ -42,7 +38,7 @@
4238
4339 struct aead_tfm {
4440 struct crypto_aead *aead;
45
- struct crypto_skcipher *null_tfm;
41
+ struct crypto_sync_skcipher *null_tfm;
4642 };
4743
4844 static inline bool aead_sufficient_data(struct sock *sk)
....@@ -75,13 +71,13 @@
7571 return af_alg_sendmsg(sock, msg, size, ivsize);
7672 }
7773
78
-static int crypto_aead_copy_sgl(struct crypto_skcipher *null_tfm,
74
+static int crypto_aead_copy_sgl(struct crypto_sync_skcipher *null_tfm,
7975 struct scatterlist *src,
8076 struct scatterlist *dst, unsigned int len)
8177 {
82
- SKCIPHER_REQUEST_ON_STACK(skreq, null_tfm);
78
+ SYNC_SKCIPHER_REQUEST_ON_STACK(skreq, null_tfm);
8379
84
- skcipher_request_set_tfm(skreq, null_tfm);
80
+ skcipher_request_set_sync_tfm(skreq, null_tfm);
8581 skcipher_request_set_callback(skreq, CRYPTO_TFM_REQ_MAY_SLEEP,
8682 NULL, NULL);
8783 skcipher_request_set_crypt(skreq, src, dst, len, NULL);
....@@ -99,7 +95,7 @@
9995 struct af_alg_ctx *ctx = ask->private;
10096 struct aead_tfm *aeadc = pask->private;
10197 struct crypto_aead *tfm = aeadc->aead;
102
- struct crypto_skcipher *null_tfm = aeadc->null_tfm;
98
+ struct crypto_sync_skcipher *null_tfm = aeadc->null_tfm;
10399 unsigned int i, as = crypto_aead_authsize(tfm);
104100 struct af_alg_async_req *areq;
105101 struct af_alg_tsgl *tsgl, *tmp;
....@@ -110,8 +106,8 @@
110106 size_t usedpages = 0; /* [in] RX bufs to be used from user */
111107 size_t processed = 0; /* [in] TX bufs to be consumed */
112108
113
- if (!ctx->used) {
114
- err = af_alg_wait_for_data(sk, flags);
109
+ if (!ctx->init || ctx->more) {
110
+ err = af_alg_wait_for_data(sk, flags, 0);
115111 if (err)
116112 return err;
117113 }
....@@ -124,7 +120,7 @@
124120
125121 /*
126122 * Make sure sufficient data is present -- note, the same check is
127
- * is also present in sendmsg/sendpage. The checks in sendpage/sendmsg
123
+ * also present in sendmsg/sendpage. The checks in sendpage/sendmsg
128124 * shall provide an information to the data sender that something is
129125 * wrong, but they are irrelevant to maintain the kernel integrity.
130126 * We need this check here too in case user space decides to not honor
....@@ -366,11 +362,9 @@
366362 .ioctl = sock_no_ioctl,
367363 .listen = sock_no_listen,
368364 .shutdown = sock_no_shutdown,
369
- .getsockopt = sock_no_getsockopt,
370365 .mmap = sock_no_mmap,
371366 .bind = sock_no_bind,
372367 .accept = sock_no_accept,
373
- .setsockopt = sock_no_setsockopt,
374368
375369 .release = af_alg_release,
376370 .sendmsg = aead_sendmsg,
....@@ -459,11 +453,9 @@
459453 .ioctl = sock_no_ioctl,
460454 .listen = sock_no_listen,
461455 .shutdown = sock_no_shutdown,
462
- .getsockopt = sock_no_getsockopt,
463456 .mmap = sock_no_mmap,
464457 .bind = sock_no_bind,
465458 .accept = sock_no_accept,
466
- .setsockopt = sock_no_setsockopt,
467459
468460 .release = af_alg_release,
469461 .sendmsg = aead_sendmsg_nokey,
....@@ -476,7 +468,7 @@
476468 {
477469 struct aead_tfm *tfm;
478470 struct crypto_aead *aead;
479
- struct crypto_skcipher *null_tfm;
471
+ struct crypto_sync_skcipher *null_tfm;
480472
481473 tfm = kzalloc(sizeof(*tfm), GFP_KERNEL);
482474 if (!tfm)
....@@ -563,12 +555,6 @@
563555
564556 INIT_LIST_HEAD(&ctx->tsgl_list);
565557 ctx->len = len;
566
- ctx->used = 0;
567
- atomic_set(&ctx->rcvused, 0);
568
- ctx->more = 0;
569
- ctx->merge = 0;
570
- ctx->enc = 0;
571
- ctx->aead_assoclen = 0;
572558 crypto_init_wait(&ctx->wait);
573559
574560 ask->private = ctx;