diff options
author | David S. Miller <davem@davemloft.net> | 2019-03-03 22:10:16 -0800 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-03-03 22:10:16 -0800 |
commit | a9836336dddf08ec5d56c0a375558e7f30c4eb3d (patch) | |
tree | 75fa2eb08c51a96fe31f037838bb0432f2bea423 /net/tls/tls_device.c | |
parent | Merge branch 'net-phy-clean-up-the-old-gen10g-functions' (diff) | |
parent | tls: Fix tls_device receive (diff) | |
download | linux-dev-a9836336dddf08ec5d56c0a375558e7f30c4eb3d.tar.xz linux-dev-a9836336dddf08ec5d56c0a375558e7f30c4eb3d.zip |
Merge branch 'tls-Fix-issues-in-tls_device'
Boris Pismenny says:
====================
tls: Fix issues in tls_device
This series fixes issues encountered in tls_device code paths,
which were introduced recently.
Additionally, this series includes a fix for tls software only receive flow,
which causes corruption of payload received by user space applications.
This series was tested using the OpenSSL integration of KTLS -
https://github.com/mellan
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tls/tls_device.c')
-rw-r--r-- | net/tls/tls_device.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/net/tls/tls_device.c b/net/tls/tls_device.c index a5c17c47d08a..4a1da837a733 100644 --- a/net/tls/tls_device.c +++ b/net/tls/tls_device.c @@ -271,7 +271,6 @@ static int tls_push_record(struct sock *sk, list_add_tail(&record->list, &offload_ctx->records_list); spin_unlock_irq(&offload_ctx->lock); offload_ctx->open_record = NULL; - set_bit(TLS_PENDING_CLOSED_RECORD, &ctx->flags); tls_advance_record_sn(sk, &ctx->tx, ctx->crypto_send.info.version); for (i = 0; i < record->num_frags; i++) { @@ -368,9 +367,11 @@ static int tls_push_data(struct sock *sk, return -sk->sk_err; timeo = sock_sndtimeo(sk, flags & MSG_DONTWAIT); - rc = tls_complete_pending_work(sk, tls_ctx, flags, &timeo); - if (rc < 0) - return rc; + if (tls_is_partially_sent_record(tls_ctx)) { + rc = tls_push_partial_record(sk, tls_ctx, flags); + if (rc < 0) + return rc; + } pfrag = sk_page_frag(sk); @@ -545,6 +546,23 @@ static int tls_device_push_pending_record(struct sock *sk, int flags) return tls_push_data(sk, &msg_iter, 0, flags, TLS_RECORD_TYPE_DATA); } +void tls_device_write_space(struct sock *sk, struct tls_context *ctx) +{ + int rc = 0; + + if (!sk->sk_write_pending && tls_is_partially_sent_record(ctx)) { + gfp_t sk_allocation = sk->sk_allocation; + + sk->sk_allocation = GFP_ATOMIC; + rc = tls_push_partial_record(sk, ctx, + MSG_DONTWAIT | MSG_NOSIGNAL); + sk->sk_allocation = sk_allocation; + } + + if (!rc) + ctx->sk_write_space(sk); +} + void handle_device_resync(struct sock *sk, u32 seq, u64 rcd_sn) { struct tls_context *tls_ctx = tls_get_ctx(sk); |