Commit ea1dd3e9 authored by Rohit Maheshwari's avatar Rohit Maheshwari Committed by Jakub Kicinski

net/tls: sendfile fails with ktls offload

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: e8f69799 ("net/tls: Add generic NIC offload infrastructure")
Signed-off-by: default avatarRohit Maheshwari <rohitm@chelsio.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 394039fe
...@@ -418,14 +418,14 @@ static int tls_push_data(struct sock *sk, ...@@ -418,14 +418,14 @@ static int tls_push_data(struct sock *sk,
struct tls_context *tls_ctx = tls_get_ctx(sk); struct tls_context *tls_ctx = tls_get_ctx(sk);
struct tls_prot_info *prot = &tls_ctx->prot_info; struct tls_prot_info *prot = &tls_ctx->prot_info;
struct tls_offload_context_tx *ctx = tls_offload_ctx_tx(tls_ctx); struct tls_offload_context_tx *ctx = tls_offload_ctx_tx(tls_ctx);
int more = flags & (MSG_SENDPAGE_NOTLAST | MSG_MORE);
struct tls_record_info *record = ctx->open_record; struct tls_record_info *record = ctx->open_record;
int tls_push_record_flags; int tls_push_record_flags;
struct page_frag *pfrag; struct page_frag *pfrag;
size_t orig_size = size; size_t orig_size = size;
u32 max_open_record_len; u32 max_open_record_len;
int copy, rc = 0; bool more = false;
bool done = false; bool done = false;
int copy, rc = 0;
long timeo; long timeo;
if (flags & if (flags &
...@@ -492,9 +492,8 @@ static int tls_push_data(struct sock *sk, ...@@ -492,9 +492,8 @@ static int tls_push_data(struct sock *sk,
if (!size) { if (!size) {
last_record: last_record:
tls_push_record_flags = flags; tls_push_record_flags = flags;
if (more) { if (flags & (MSG_SENDPAGE_NOTLAST | MSG_MORE)) {
tls_ctx->pending_open_record_frags = more = true;
!!record->num_frags;
break; break;
} }
...@@ -526,6 +525,8 @@ static int tls_push_data(struct sock *sk, ...@@ -526,6 +525,8 @@ static int tls_push_data(struct sock *sk,
} }
} while (!done); } while (!done);
tls_ctx->pending_open_record_frags = more;
if (orig_size - size > 0) if (orig_size - size > 0)
rc = orig_size - size; rc = orig_size - size;
......
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