summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRohit Maheshwari <rohitm@chelsio.com>2020-10-08 00:10:21 +0530
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-10-29 09:54:56 +0100
commitb2d31640d4045d8bb7cf25d2bd53ce8d1b14fb40 (patch)
tree4a126cbc15ac5d0a6259b7d60139a2b25b33a44f
parent7bf51ad6408fc39ea6b80c23f0fafcfe30f49377 (diff)
downloadlinux-stable-b2d31640d4045d8bb7cf25d2bd53ce8d1b14fb40.tar.gz
linux-stable-b2d31640d4045d8bb7cf25d2bd53ce8d1b14fb40.tar.bz2
linux-stable-b2d31640d4045d8bb7cf25d2bd53ce8d1b14fb40.zip
net/tls: sendfile fails with ktls offload
[ Upstream commit ea1dd3e9d080c961b9a451130b61c72dc9a5397b ] At first when sendpage gets called, if there is more data, 'more' in tls_push_data() gets set which later sets pending_open_record_frags, but when there is no more data in file left, and last time tls_push_data() gets called, pending_open_record_frags doesn't get reset. And later when 2 bytes of encrypted alert comes as sendmsg, it first checks for pending_open_record_frags, and since this is set, it creates a record with 0 data bytes to encrypt, meaning record length is prepend_size + tag_size only, which causes problem. We should set/reset pending_open_record_frags based on more bit. Fixes: e8f69799810c ("net/tls: Add generic NIC offload infrastructure") Signed-off-by: Rohit Maheshwari <rohitm@chelsio.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--net/tls/tls_device.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/net/tls/tls_device.c b/net/tls/tls_device.c
index 575d62130578..dd0fc2aa6875 100644
--- a/net/tls/tls_device.c
+++ b/net/tls/tls_device.c
@@ -351,13 +351,13 @@ static int tls_push_data(struct sock *sk,
struct tls_context *tls_ctx = tls_get_ctx(sk);
struct tls_offload_context_tx *ctx = tls_offload_ctx_tx(tls_ctx);
int tls_push_record_flags = flags | MSG_SENDPAGE_NOTLAST;
- int more = flags & (MSG_SENDPAGE_NOTLAST | MSG_MORE);
struct tls_record_info *record = ctx->open_record;
struct page_frag *pfrag;
size_t orig_size = size;
u32 max_open_record_len;
- int copy, rc = 0;
+ bool more = false;
bool done = false;
+ int copy, rc = 0;
long timeo;
if (flags &
@@ -422,9 +422,8 @@ handle_error:
if (!size) {
last_record:
tls_push_record_flags = flags;
- if (more) {
- tls_ctx->pending_open_record_frags =
- record->num_frags;
+ if (flags & (MSG_SENDPAGE_NOTLAST | MSG_MORE)) {
+ more = true;
break;
}
@@ -445,6 +444,8 @@ last_record:
}
} while (!done);
+ tls_ctx->pending_open_record_frags = more;
+
if (orig_size - size > 0)
rc = orig_size - size;