Skip to content

Commit 41532b7

Browse files
qsnkuba-moo
authored andcommitted
tls: separate no-async decryption request handling from async
If we're not doing async, the handling is much simpler. There's no reference counting, we just need to wait for the completion to wake us up and return its result. We should preferably also use a separate crypto_wait. I'm not seeing a UAF as I did in the past, I think aec7961 ("tls: fix race between async notify and socket close") took care of it. This will make the next fix easier. Signed-off-by: Sabrina Dubroca <[email protected]> Link: https://lore.kernel.org/r/47bde5f649707610eaef9f0d679519966fc31061.1709132643.git.sd@queasysnail.net Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 6caaf10 commit 41532b7

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

net/tls/tls_sw.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,15 @@ static int tls_do_decryption(struct sock *sk,
274274
DEBUG_NET_WARN_ON_ONCE(atomic_read(&ctx->decrypt_pending) < 1);
275275
atomic_inc(&ctx->decrypt_pending);
276276
} else {
277+
DECLARE_CRYPTO_WAIT(wait);
278+
277279
aead_request_set_callback(aead_req,
278280
CRYPTO_TFM_REQ_MAY_BACKLOG,
279-
crypto_req_done, &ctx->async_wait);
281+
crypto_req_done, &wait);
282+
ret = crypto_aead_decrypt(aead_req);
283+
if (ret == -EINPROGRESS || ret == -EBUSY)
284+
ret = crypto_wait_req(ret, &wait);
285+
return ret;
280286
}
281287

282288
ret = crypto_aead_decrypt(aead_req);
@@ -285,10 +291,7 @@ static int tls_do_decryption(struct sock *sk,
285291
ret = ret ?: -EINPROGRESS;
286292
}
287293
if (ret == -EINPROGRESS) {
288-
if (darg->async)
289-
return 0;
290-
291-
ret = crypto_wait_req(ret, &ctx->async_wait);
294+
return 0;
292295
} else if (darg->async) {
293296
atomic_dec(&ctx->decrypt_pending);
294297
}

0 commit comments

Comments
 (0)