提交 cd846279 编写于 作者: M Maxim Mikityanskiy 提交者: Zheng Zengkai

tls: Skip tls_append_frag on zero copy size

stable inclusion
from stable-v5.10.114
commit 1781beb87935d39f47af6553e4b3581f834ea79b
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5IY1V

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=1781beb87935d39f47af6553e4b3581f834ea79b

--------------------------------

[ Upstream commit a0df7194 ]

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: e8f69799 ("net/tls: Add generic NIC offload infrastructure")
Signed-off-by: NMaxim Mikityanskiy <maximmi@nvidia.com>
Reviewed-by: NTariq Toukan <tariqt@nvidia.com>
Link: https://lore.kernel.org/r/20220426154949.159055-1-maximmi@nvidia.comSigned-off-by: NJakub Kicinski <kuba@kernel.org>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
上级 17f8d42c
...@@ -483,11 +483,13 @@ static int tls_push_data(struct sock *sk, ...@@ -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, size, (pfrag->size - pfrag->offset));
copy = min_t(size_t, copy, (max_open_record_len - record->len)); copy = min_t(size_t, copy, (max_open_record_len - record->len));
rc = tls_device_copy_data(page_address(pfrag->page) + if (copy) {
pfrag->offset, copy, msg_iter); rc = tls_device_copy_data(page_address(pfrag->page) +
if (rc) pfrag->offset, copy, msg_iter);
goto handle_error; if (rc)
tls_append_frag(record, pfrag, copy); goto handle_error;
tls_append_frag(record, pfrag, copy);
}
size -= copy; size -= copy;
if (!size) { if (!size) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册