Skip to content

Commit 41da022

Browse files
Herbert XuPlaidCat
authored andcommitted
crypto: algif_aead - snapshot IV for async AEAD requests
jira VULN-181880 cve-bf CVE-2026-31431 commit-author Douya Le <ldy3087146292@gmail.com> commit 5aa58c3 AF_ALG AEAD AIO requests currently use the socket-wide IV buffer during request processing. For async requests, later socket activity can update that shared state before the original request has fully completed, which can lead to inconsistent IV handling. Snapshot the IV into per-request storage when preparing the AEAD request, so in-flight operations no longer depend on mutable socket state. Fixes: d887c52 ("crypto: algif_aead - overhaul memory management") Cc: stable@kernel.org Reported-by: Yuan Tan <yuantan098@gmail.com> Reported-by: Yifan Wu <yifanwucs@gmail.com> Reported-by: Juefei Pu <tomapufckgml@gmail.com> Reported-by: Xin Liu <bird@lzu.edu.cn> Co-developed-by: Luxing Yin <tr0jan@lzu.edu.cn> Signed-off-by: Luxing Yin <tr0jan@lzu.edu.cn> Tested-by: Yucheng Lu <kanolyc@gmail.com> Signed-off-by: Douya Le <ldy3087146292@gmail.com> Signed-off-by: Ren Wei <n05ec@lzu.edu.cn> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 99b3a9a commit 41da022

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

crypto/algif_aead.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,10 @@ static int _aead_recvmsg(struct socket *sock, struct msghdr *msg,
9696
struct crypto_aead *tfm = aeadc->aead;
9797
struct crypto_sync_skcipher *null_tfm = aeadc->null_tfm;
9898
unsigned int as = crypto_aead_authsize(tfm);
99+
unsigned int ivsize = crypto_aead_ivsize(tfm);
99100
struct af_alg_async_req *areq;
100101
struct scatterlist *rsgl_src, *tsgl_src = NULL;
102+
void *iv;
101103
int err = 0;
102104
size_t used = 0; /* [in] TX bufs to be en/decrypted */
103105
size_t outlen = 0; /* [out] RX bufs produced by kernel */
@@ -149,10 +151,14 @@ static int _aead_recvmsg(struct socket *sock, struct msghdr *msg,
149151

150152
/* Allocate cipher request for current operation. */
151153
areq = af_alg_alloc_areq(sk, sizeof(struct af_alg_async_req) +
152-
crypto_aead_reqsize(tfm));
154+
crypto_aead_reqsize(tfm) + ivsize);
153155
if (IS_ERR(areq))
154156
return PTR_ERR(areq);
155157

158+
iv = (u8 *)aead_request_ctx(&areq->cra_u.aead_req) +
159+
crypto_aead_reqsize(tfm);
160+
memcpy(iv, ctx->iv, ivsize);
161+
156162
/* convert iovecs of output buffers into RX SGL */
157163
err = af_alg_get_rsgl(sk, msg, flags, areq, outlen, &usedpages);
158164
if (err)
@@ -214,7 +220,7 @@ static int _aead_recvmsg(struct socket *sock, struct msghdr *msg,
214220

215221
/* Initialize the crypto operation */
216222
aead_request_set_crypt(&areq->cra_u.aead_req, tsgl_src,
217-
areq->first_rsgl.sgl.sg, used, ctx->iv);
223+
areq->first_rsgl.sgl.sg, used, iv);
218224
aead_request_set_ad(&areq->cra_u.aead_req, ctx->aead_assoclen);
219225
aead_request_set_tfm(&areq->cra_u.aead_req, tfm);
220226

0 commit comments

Comments
 (0)