Commit f314bfee authored by Jakub Kicinski's avatar Jakub Kicinski Committed by David S. Miller

tls: rx: return the already-copied data on crypto error

async crypto handler will report the socket error no need
to report it again. We can, however, let the data we already
copied be reported to user space but we need to make sure
the error will be reported next time around.
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4dcdd971
...@@ -1744,6 +1744,11 @@ int tls_sw_recvmsg(struct sock *sk, ...@@ -1744,6 +1744,11 @@ int tls_sw_recvmsg(struct sock *sk,
lock_sock(sk); lock_sock(sk);
bpf_strp_enabled = sk_psock_strp_enabled(psock); bpf_strp_enabled = sk_psock_strp_enabled(psock);
/* If crypto failed the connection is broken */
err = ctx->async_wait.err;
if (err)
goto end;
/* Process pending decrypted records. It must be non-zero-copy */ /* Process pending decrypted records. It must be non-zero-copy */
err = process_rx_list(ctx, msg, &control, 0, len, false, is_peek); err = process_rx_list(ctx, msg, &control, 0, len, false, is_peek);
if (err < 0) if (err < 0)
...@@ -1874,7 +1879,7 @@ int tls_sw_recvmsg(struct sock *sk, ...@@ -1874,7 +1879,7 @@ int tls_sw_recvmsg(struct sock *sk,
recv_end: recv_end:
if (async) { if (async) {
int pending; int ret, pending;
/* Wait for all previously submitted records to be decrypted */ /* Wait for all previously submitted records to be decrypted */
spin_lock_bh(&ctx->decrypt_compl_lock); spin_lock_bh(&ctx->decrypt_compl_lock);
...@@ -1882,11 +1887,10 @@ int tls_sw_recvmsg(struct sock *sk, ...@@ -1882,11 +1887,10 @@ int tls_sw_recvmsg(struct sock *sk,
pending = atomic_read(&ctx->decrypt_pending); pending = atomic_read(&ctx->decrypt_pending);
spin_unlock_bh(&ctx->decrypt_compl_lock); spin_unlock_bh(&ctx->decrypt_compl_lock);
if (pending) { if (pending) {
err = crypto_wait_req(-EINPROGRESS, &ctx->async_wait); ret = crypto_wait_req(-EINPROGRESS, &ctx->async_wait);
if (err) { if (ret) {
/* one of async decrypt failed */ if (err >= 0 || err == -EINPROGRESS)
tls_err_abort(sk, err); err = ret;
copied = 0;
decrypted = 0; decrypted = 0;
goto end; goto end;
} }
......
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