Skip to content

Commit c0ab473

Browse files
nxa22042davem330
authored andcommitted
net/tls: Do not use async crypto for non-data records
Addition of tls1.3 support broke tls1.2 handshake when async crypto accelerator is used. This is because the record type for non-data records is not propagated to user application. Also when async decryption happens, the decryption does not stop when two different types of records get dequeued and submitted for decryption. To address it, we decrypt tls1.2 non-data records in synchronous way. We check whether the record we just processed has same type as the previous one before checking for async condition and jumping to dequeue next record. Fixes: 130b392 ("net: tls: Add tls 1.3 support") Signed-off-by: Vakul Garg <vakul.garg@nxp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent fde55ea commit c0ab473

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

net/tls/tls_sw.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1645,10 +1645,10 @@ int tls_sw_recvmsg(struct sock *sk,
16451645

16461646
do {
16471647
bool retain_skb = false;
1648-
bool async = false;
16491648
bool zc = false;
16501649
int to_decrypt;
16511650
int chunk = 0;
1651+
bool async;
16521652

16531653
skb = tls_wait_data(sk, psock, flags, timeo, &err);
16541654
if (!skb) {
@@ -1674,18 +1674,21 @@ int tls_sw_recvmsg(struct sock *sk,
16741674
tls_ctx->crypto_recv.info.version != TLS_1_3_VERSION)
16751675
zc = true;
16761676

1677+
/* Do not use async mode if record is non-data */
1678+
if (ctx->control == TLS_RECORD_TYPE_DATA)
1679+
async = ctx->async_capable;
1680+
else
1681+
async = false;
1682+
16771683
err = decrypt_skb_update(sk, skb, &msg->msg_iter,
1678-
&chunk, &zc, ctx->async_capable);
1684+
&chunk, &zc, async);
16791685
if (err < 0 && err != -EINPROGRESS) {
16801686
tls_err_abort(sk, EBADMSG);
16811687
goto recv_end;
16821688
}
16831689

1684-
if (err == -EINPROGRESS) {
1685-
async = true;
1690+
if (err == -EINPROGRESS)
16861691
num_async++;
1687-
goto pick_next_record;
1688-
}
16891692

16901693
if (!cmsg) {
16911694
int cerr;
@@ -1704,6 +1707,9 @@ int tls_sw_recvmsg(struct sock *sk,
17041707
goto recv_end;
17051708
}
17061709

1710+
if (async)
1711+
goto pick_next_record;
1712+
17071713
if (!zc) {
17081714
if (rxm->full_len > len) {
17091715
retain_skb = true;

0 commit comments

Comments
 (0)