Commit d069b780 authored by Boris Pismenny's avatar Boris Pismenny Committed by David S. Miller

tls: Fix tls_device receive

Currently, the receive function fails to handle records already
decrypted by the device due to the commit mentioned below.

This commit advances the TLS record sequence number and prepares the context
to handle the next record.

Fixes: fedf201e ("net: tls: Refactor control message handling on recv")
Signed-off-by: default avatarBoris Pismenny <borisp@mellanox.com>
Reviewed-by: default avatarEran Ben Elisha <eranbe@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7754bd63
...@@ -1467,13 +1467,16 @@ static int decrypt_skb_update(struct sock *sk, struct sk_buff *skb, ...@@ -1467,13 +1467,16 @@ static int decrypt_skb_update(struct sock *sk, struct sk_buff *skb,
struct strp_msg *rxm = strp_msg(skb); struct strp_msg *rxm = strp_msg(skb);
int err = 0; int err = 0;
if (!ctx->decrypted) {
#ifdef CONFIG_TLS_DEVICE #ifdef CONFIG_TLS_DEVICE
err = tls_device_decrypted(sk, skb); err = tls_device_decrypted(sk, skb);
if (err < 0) if (err < 0)
return err; return err;
#endif #endif
/* Still not decrypted after tls_device */
if (!ctx->decrypted) { if (!ctx->decrypted) {
err = decrypt_internal(sk, skb, dest, NULL, chunk, zc, async); err = decrypt_internal(sk, skb, dest, NULL, chunk, zc,
async);
if (err < 0) { if (err < 0) {
if (err == -EINPROGRESS) if (err == -EINPROGRESS)
tls_advance_record_sn(sk, &tls_ctx->rx, tls_advance_record_sn(sk, &tls_ctx->rx,
...@@ -1481,9 +1484,9 @@ static int decrypt_skb_update(struct sock *sk, struct sk_buff *skb, ...@@ -1481,9 +1484,9 @@ static int decrypt_skb_update(struct sock *sk, struct sk_buff *skb,
return err; return err;
} }
}
rxm->full_len -= padding_length(ctx, tls_ctx, skb); rxm->full_len -= padding_length(ctx, tls_ctx, skb);
rxm->offset += prot->prepend_size; rxm->offset += prot->prepend_size;
rxm->full_len -= prot->overhead_size; rxm->full_len -= prot->overhead_size;
tls_advance_record_sn(sk, &tls_ctx->rx, version); tls_advance_record_sn(sk, &tls_ctx->rx, version);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment