tls: Skip tls_append_frag on zero copy size
Subsystems (3)
PATCH v2 1/1 tls: Skip tls_append_frag on zero copy size
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.
--- net/tls/tls_device.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
net/tls/tls_device.c +7 -5
@@ -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) {
Signature · 1 line
2.25.1
Quoted 10 lines · On Tue, 26 Apr 2022 18:49:49 +0300 Maxim Mikityanskiy wrote:
Calling
tls_append_fragwhenmax_open_record_len==record->lenmight add an empty fragment to the TLS record if the call happens to be on the page boundary. Normallytls_append_fragcoalesces 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 withbyte_count== 0, which will confuse the NIC and lead to a CQE error.
Quoted 7 lines
This commit fixes the described issue by skipping
tls_append_fragon zero size to avoid adding empty fragments. The fix is not in the driver, because an empty fragment is hardly the desired behavior.Fixes e8f69799810c ("net/tls: Add generic NIC offload infrastructure")Signed-off-by Maxim Mikityanskiy <[email protected]>Reviewed-by Tariq Toukan <[email protected]>
This patch was applied to netdev/net.git (master) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (master)
by Jakub Kicinski <[email protected]>:
Quoted 11 lines · On Tue, 26 Apr 2022 18:49:49 +0300 you wrote:
Calling
tls_append_fragwhenmax_open_record_len==record->lenmight add an empty fragment to the TLS record if the call happens to be on the page boundary. Normallytls_append_fragcoalesces 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 withbyte_count== 0, which will confuse the NIC and lead to a CQE error.[...]
Here is the summary with links:
- [net,v2] tls: Skip tls_append_frag on zero copy size
https://git.kernel.org/netdev/net/c/a0df71948e95
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html