Skip to content

Commit

Permalink
tls: Skip tls_append_frag on zero copy size
Browse files Browse the repository at this point in the history
Calling tls_append_frag when max_open_record_len == record->len might
add an empty fragment to the TLS record if the call happens to be on the
page boundary. Normally tls_append_frag coalesces the zero-sized
fragment to the previous one, but not if it's on page boundary.

If a resync happens then, the mlx5 driver posts dump WQEs in
tx_post_resync_dump, and the empty fragment may become a data segment
with byte_count == 0, which will confuse the NIC and lead to a CQE
error.

This commit fixes the described issue by skipping tls_append_frag on
zero size to avoid adding empty fragments. The fix is not in the driver,
because an empty fragment is hardly the desired behavior.

Fixes: e8f6979 ("net/tls: Add generic NIC offload infrastructure")
Signed-off-by: Maxim Mikityanskiy <maximmi@nvidia.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://lore.kernel.org/r/20220426154949.159055-1-maximmi@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
nvmmax authored and kuba-moo committed Apr 27, 2022
1 parent 347cb5d commit a0df719
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions net/tls/tls_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -483,11 +483,13 @@ static int tls_push_data(struct sock *sk,
copy = min_t(size_t, size, (pfrag->size - pfrag->offset));
copy = min_t(size_t, copy, (max_open_record_len - record->len));

rc = tls_device_copy_data(page_address(pfrag->page) +
pfrag->offset, copy, msg_iter);
if (rc)
goto handle_error;
tls_append_frag(record, pfrag, copy);
if (copy) {
rc = tls_device_copy_data(page_address(pfrag->page) +
pfrag->offset, copy, msg_iter);
if (rc)
goto handle_error;
tls_append_frag(record, pfrag, copy);
}

size -= copy;
if (!size) {
Expand Down

0 comments on commit a0df719

Please sign in to comment.