Skip to content

Commit f6554d0

Browse files
nvmmaxsmb49
authored andcommitted
tls: Skip tls_append_frag on zero copy size
BugLink: https://bugs.launchpad.net/bugs/1979014 [ Upstream commit a0df719 ] 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 <[email protected]> Reviewed-by: Tariq Toukan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Kamal Mostafa <[email protected]> Signed-off-by: Stefan Bader <[email protected]>
1 parent f769834 commit f6554d0

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

net/tls/tls_device.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -470,11 +470,13 @@ static int tls_push_data(struct sock *sk,
470470
copy = min_t(size_t, size, (pfrag->size - pfrag->offset));
471471
copy = min_t(size_t, copy, (max_open_record_len - record->len));
472472

473-
rc = tls_device_copy_data(page_address(pfrag->page) +
474-
pfrag->offset, copy, msg_iter);
475-
if (rc)
476-
goto handle_error;
477-
tls_append_frag(record, pfrag, copy);
473+
if (copy) {
474+
rc = tls_device_copy_data(page_address(pfrag->page) +
475+
pfrag->offset, copy, msg_iter);
476+
if (rc)
477+
goto handle_error;
478+
tls_append_frag(record, pfrag, copy);
479+
}
478480

479481
size -= copy;
480482
if (!size) {

0 commit comments

Comments
 (0)