Skip to contentSkip to conversation

tls: separate no-async decryption request handling from async

PATCH Applied Wengang Wang 2 participants 2 messages Aug 3 – Aug 4 Stable branch

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tls: separate no-async decryption request handling from async

From: Sabrina Dubroca <[email protected]>

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 aec7961916f3 ("tls: fix race between async notify and socket close") took care of it.

This will make the next fix easier.

CVE: CVE-2024-58240

Conflicts:
net/tls/tls_sw.c

---
 net/tls/tls_sw.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
net/tls/tls_sw.c +10 -7
index 1732e3549a57..29650fa54666 100644
@@ -257,18 +257,21 @@ static int tls_do_decryption(struct sock *sk,
 					  tls_decrypt_done, skb);
 		atomic_inc(&ctx->decrypt_pending);
 	} else {
+		DECLARE_CRYPTO_WAIT(wait);
+
 		aead_request_set_callback(aead_req,
 					  CRYPTO_TFM_REQ_MAY_BACKLOG,
-					  crypto_req_done, &ctx->async_wait);
+					  crypto_req_done, &wait);
+
+		ret = crypto_aead_decrypt(aead_req);
+		if (ret == -EINPROGRESS || ret == -EBUSY)
+			ret = crypto_wait_req(ret, &wait);
+		return ret;
 	}
 
 	ret = crypto_aead_decrypt(aead_req);
-	if (ret == -EINPROGRESS) {
-		if (async)
-			return ret;
-
-		ret = crypto_wait_req(ret, &ctx->async_wait);
-	}
+	if (ret == -EINPROGRESS)
+		return ret;
 
 	if (async)
 		atomic_dec(&ctx->decrypt_pending);
Signature · 1 line
2.50.1 (Apple Git-155)
maintainer Applied
#1 lore raw
Quoted 1 line · Wengang Wang

Subject: [PATCH 5.10.y] tls: separate no-async decryption request handling from async

Queued for 5.10, thanks.

Signature · 2 lines
Thanks,
Sasha