.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * algif_aead: User-space interface for AEAD algorithms |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2014, Stephan Mueller <smueller@chronox.de> |
---|
5 | 6 | * |
---|
6 | 7 | * 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. |
---|
12 | 8 | * |
---|
13 | 9 | * The following concept of the memory management is used: |
---|
14 | 10 | * |
---|
.. | .. |
---|
42 | 38 | |
---|
43 | 39 | struct aead_tfm { |
---|
44 | 40 | struct crypto_aead *aead; |
---|
45 | | - struct crypto_skcipher *null_tfm; |
---|
| 41 | + struct crypto_sync_skcipher *null_tfm; |
---|
46 | 42 | }; |
---|
47 | 43 | |
---|
48 | 44 | static inline bool aead_sufficient_data(struct sock *sk) |
---|
.. | .. |
---|
75 | 71 | return af_alg_sendmsg(sock, msg, size, ivsize); |
---|
76 | 72 | } |
---|
77 | 73 | |
---|
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, |
---|
79 | 75 | struct scatterlist *src, |
---|
80 | 76 | struct scatterlist *dst, unsigned int len) |
---|
81 | 77 | { |
---|
82 | | - SKCIPHER_REQUEST_ON_STACK(skreq, null_tfm); |
---|
| 78 | + SYNC_SKCIPHER_REQUEST_ON_STACK(skreq, null_tfm); |
---|
83 | 79 | |
---|
84 | | - skcipher_request_set_tfm(skreq, null_tfm); |
---|
| 80 | + skcipher_request_set_sync_tfm(skreq, null_tfm); |
---|
85 | 81 | skcipher_request_set_callback(skreq, CRYPTO_TFM_REQ_MAY_SLEEP, |
---|
86 | 82 | NULL, NULL); |
---|
87 | 83 | skcipher_request_set_crypt(skreq, src, dst, len, NULL); |
---|
.. | .. |
---|
99 | 95 | struct af_alg_ctx *ctx = ask->private; |
---|
100 | 96 | struct aead_tfm *aeadc = pask->private; |
---|
101 | 97 | 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; |
---|
103 | 99 | unsigned int i, as = crypto_aead_authsize(tfm); |
---|
104 | 100 | struct af_alg_async_req *areq; |
---|
105 | 101 | struct af_alg_tsgl *tsgl, *tmp; |
---|
.. | .. |
---|
110 | 106 | size_t usedpages = 0; /* [in] RX bufs to be used from user */ |
---|
111 | 107 | size_t processed = 0; /* [in] TX bufs to be consumed */ |
---|
112 | 108 | |
---|
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); |
---|
115 | 111 | if (err) |
---|
116 | 112 | return err; |
---|
117 | 113 | } |
---|
.. | .. |
---|
124 | 120 | |
---|
125 | 121 | /* |
---|
126 | 122 | * 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 |
---|
128 | 124 | * shall provide an information to the data sender that something is |
---|
129 | 125 | * wrong, but they are irrelevant to maintain the kernel integrity. |
---|
130 | 126 | * We need this check here too in case user space decides to not honor |
---|
.. | .. |
---|
366 | 362 | .ioctl = sock_no_ioctl, |
---|
367 | 363 | .listen = sock_no_listen, |
---|
368 | 364 | .shutdown = sock_no_shutdown, |
---|
369 | | - .getsockopt = sock_no_getsockopt, |
---|
370 | 365 | .mmap = sock_no_mmap, |
---|
371 | 366 | .bind = sock_no_bind, |
---|
372 | 367 | .accept = sock_no_accept, |
---|
373 | | - .setsockopt = sock_no_setsockopt, |
---|
374 | 368 | |
---|
375 | 369 | .release = af_alg_release, |
---|
376 | 370 | .sendmsg = aead_sendmsg, |
---|
.. | .. |
---|
459 | 453 | .ioctl = sock_no_ioctl, |
---|
460 | 454 | .listen = sock_no_listen, |
---|
461 | 455 | .shutdown = sock_no_shutdown, |
---|
462 | | - .getsockopt = sock_no_getsockopt, |
---|
463 | 456 | .mmap = sock_no_mmap, |
---|
464 | 457 | .bind = sock_no_bind, |
---|
465 | 458 | .accept = sock_no_accept, |
---|
466 | | - .setsockopt = sock_no_setsockopt, |
---|
467 | 459 | |
---|
468 | 460 | .release = af_alg_release, |
---|
469 | 461 | .sendmsg = aead_sendmsg_nokey, |
---|
.. | .. |
---|
476 | 468 | { |
---|
477 | 469 | struct aead_tfm *tfm; |
---|
478 | 470 | struct crypto_aead *aead; |
---|
479 | | - struct crypto_skcipher *null_tfm; |
---|
| 471 | + struct crypto_sync_skcipher *null_tfm; |
---|
480 | 472 | |
---|
481 | 473 | tfm = kzalloc(sizeof(*tfm), GFP_KERNEL); |
---|
482 | 474 | if (!tfm) |
---|
.. | .. |
---|
563 | 555 | |
---|
564 | 556 | INIT_LIST_HEAD(&ctx->tsgl_list); |
---|
565 | 557 | 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; |
---|
572 | 558 | crypto_init_wait(&ctx->wait); |
---|
573 | 559 | |
---|
574 | 560 | ask->private = ctx; |
---|