Skip to content

Commit ee1f419

Browse files
rmchelsiogregkh
authored andcommitted
net/tls: sendfile fails with ktls offload
[ Upstream commit ea1dd3e ] 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: e8f6979 ("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>
1 parent 4f33f7c commit ee1f419

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

net/tls/tls_device.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -418,14 +418,14 @@ static int tls_push_data(struct sock *sk,
418418
struct tls_context *tls_ctx = tls_get_ctx(sk);
419419
struct tls_prot_info *prot = &tls_ctx->prot_info;
420420
struct tls_offload_context_tx *ctx = tls_offload_ctx_tx(tls_ctx);
421-
int more = flags & (MSG_SENDPAGE_NOTLAST | MSG_MORE);
422421
struct tls_record_info *record = ctx->open_record;
423422
int tls_push_record_flags;
424423
struct page_frag *pfrag;
425424
size_t orig_size = size;
426425
u32 max_open_record_len;
427-
int copy, rc = 0;
426+
bool more = false;
428427
bool done = false;
428+
int copy, rc = 0;
429429
long timeo;
430430

431431
if (flags &
@@ -492,9 +492,8 @@ static int tls_push_data(struct sock *sk,
492492
if (!size) {
493493
last_record:
494494
tls_push_record_flags = flags;
495-
if (more) {
496-
tls_ctx->pending_open_record_frags =
497-
!!record->num_frags;
495+
if (flags & (MSG_SENDPAGE_NOTLAST | MSG_MORE)) {
496+
more = true;
498497
break;
499498
}
500499

@@ -526,6 +525,8 @@ static int tls_push_data(struct sock *sk,
526525
}
527526
} while (!done);
528527

528+
tls_ctx->pending_open_record_frags = more;
529+
529530
if (orig_size - size > 0)
530531
rc = orig_size - size;
531532

0 commit comments

Comments
 (0)