Skip to content

Commit 7754bd6

Browse files
Eran Ben Elishadavem330
authored andcommitted
tls: Fix mixing between async capable and async
Today, tls_sw_recvmsg is capable of using asynchronous mode to handle application data TLS records. Moreover, it assumes that if the cipher can be handled asynchronously, then all packets will be processed asynchronously. However, this assumption is not always true. Specifically, for AES-GCM in TLS1.2, it causes data corruption, and breaks user applications. This patch fixes this problem by separating the async capability from the decryption operation result. Fixes: c0ab473 ("net/tls: Do not use async crypto for non-data records") Signed-off-by: Eran Ben Elisha <eranbe@mellanox.com> Reviewed-by: Boris Pismenny <borisp@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 7463d3a commit 7754bd6

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

net/tls/tls_sw.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1693,7 +1693,8 @@ int tls_sw_recvmsg(struct sock *sk,
16931693
bool zc = false;
16941694
int to_decrypt;
16951695
int chunk = 0;
1696-
bool async;
1696+
bool async_capable;
1697+
bool async = false;
16971698

16981699
skb = tls_wait_data(sk, psock, flags, timeo, &err);
16991700
if (!skb) {
@@ -1727,21 +1728,23 @@ int tls_sw_recvmsg(struct sock *sk,
17271728

17281729
/* Do not use async mode if record is non-data */
17291730
if (ctx->control == TLS_RECORD_TYPE_DATA)
1730-
async = ctx->async_capable;
1731+
async_capable = ctx->async_capable;
17311732
else
1732-
async = false;
1733+
async_capable = false;
17331734

17341735
err = decrypt_skb_update(sk, skb, &msg->msg_iter,
1735-
&chunk, &zc, async);
1736+
&chunk, &zc, async_capable);
17361737
if (err < 0 && err != -EINPROGRESS) {
17371738
tls_err_abort(sk, EBADMSG);
17381739
goto recv_end;
17391740
}
17401741

1741-
if (err == -EINPROGRESS)
1742+
if (err == -EINPROGRESS) {
1743+
async = true;
17421744
num_async++;
1743-
else if (prot->version == TLS_1_3_VERSION)
1745+
} else if (prot->version == TLS_1_3_VERSION) {
17441746
tlm->control = ctx->control;
1747+
}
17451748

17461749
/* If the type of records being processed is not known yet,
17471750
* set it to record type just dequeued. If it is already known,

0 commit comments

Comments
 (0)