Skip to content

Commit 84a8335

Browse files
chuckleverPaolo Abeni
authored andcommitted
tls: Purge async_hold in tls_decrypt_async_wait()
The async_hold queue pins encrypted input skbs while the AEAD engine references their scatterlist data. Once tls_decrypt_async_wait() returns, every AEAD operation has completed and the engine no longer references those skbs, so they can be freed unconditionally. A subsequent patch adds batch async decryption to tls_sw_read_sock(), introducing a new call site that must drain pending AEAD operations and release held skbs. Move __skb_queue_purge(&ctx->async_hold) into tls_decrypt_async_wait() so the purge is centralized and every caller -- recvmsg's drain path, the -EBUSY fallback in tls_do_decryption(), and the new read_sock batch path -- releases held skbs on synchronization without each site managing the purge independently. This fixes a leak when tls_strp_msg_hold() fails part-way through, after having added some cloned skbs to the async_hold queue. tls_decrypt_sg() will then call tls_decrypt_async_wait() to process all pending decrypts, and drop back to synchronous mode, but tls_sw_recvmsg() only flushes the async_hold queue when one record has been processed in "fully-async" mode, which may not be the case here. Signed-off-by: Chuck Lever <[email protected]> Reported-by: Yiming Qian <[email protected]> Fixes: b8a6ff8 ("tls: wait for pending async decryptions if tls_strp_msg_hold fails") Link: https://patch.msgid.link/[email protected] [[email protected]: added leak comment] Signed-off-by: Paolo Abeni <[email protected]>
1 parent c4ea7d8 commit 84a8335

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

net/tls/tls_sw.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ static int tls_decrypt_async_wait(struct tls_sw_context_rx *ctx)
246246
crypto_wait_req(-EINPROGRESS, &ctx->async_wait);
247247
atomic_inc(&ctx->decrypt_pending);
248248

249+
__skb_queue_purge(&ctx->async_hold);
249250
return ctx->async_wait.err;
250251
}
251252

@@ -2225,7 +2226,6 @@ int tls_sw_recvmsg(struct sock *sk,
22252226

22262227
/* Wait for all previously submitted records to be decrypted */
22272228
ret = tls_decrypt_async_wait(ctx);
2228-
__skb_queue_purge(&ctx->async_hold);
22292229

22302230
if (ret) {
22312231
if (err >= 0 || err == -EINPROGRESS)

0 commit comments

Comments
 (0)