From: Jakub Kicinski <kuba@kernel.org>
To: Adrien Moulin <amoulin@corp.free.fr>
Cc: Boris Pismenny <borisp@nvidia.com>,
John Fastabend <john.fastabend@gmail.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Tariq Toukan <tariqt@nvidia.com>
Subject: Re: TLS zerocopy sendfile offset causes data corruption
Date: Fri, 3 Mar 2023 17:17:56 -0800 [thread overview]
Message-ID: <20230303171756.38a8a43e@kernel.org> (raw)
In-Reply-To: <61481278.42813558.1677845235112.JavaMail.zimbra@corp.free.fr>
On Fri, 3 Mar 2023 13:07:15 +0100 (CET) Adrien Moulin wrote:
> When doing a sendfile call on a TLS_TX_ZEROCOPY_RO-enabled socket with an offset that is neither zero nor 4k-aligned, and with a "count" bigger than a single TLS record, part of the data received will be corrupted.
>
> I am seeing this on 5.19 and 6.2.1 (x86_64) with a ConnectX-6 Dx NIC, with TLS NIC offload including sendfile otherwise working perfectly when not using TLS_TX_ZEROCOPY_RO.
> I have a simple reproducer program available here https://gist.github.com/elyosh/922e6c15f8d4d7102c8ac9508b0cdc3b
Would you be able to test potential fixes? Unfortunately testing
requires access to the right HW :(
I think the offset needs to be incremented, so:
diff --git a/net/tls/tls_device.c b/net/tls/tls_device.c
index 6c593788dc25..a7cc4f9faac2 100644
--- a/net/tls/tls_device.c
+++ b/net/tls/tls_device.c
@@ -508,6 +508,8 @@ static int tls_push_data(struct sock *sk,
zc_pfrag.offset = iter_offset.offset;
zc_pfrag.size = copy;
tls_append_frag(record, &zc_pfrag, copy);
+
+ iter_offset.offset += copy;
} else if (copy) {
copy = min_t(size_t, copy, pfrag->size - pfrag->offset);
next prev parent reply other threads:[~2023-03-04 1:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-03 12:07 TLS zerocopy sendfile offset causes data corruption Adrien Moulin
2023-03-04 1:17 ` Jakub Kicinski [this message]
2023-03-04 10:40 ` Adrien Moulin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230303171756.38a8a43e@kernel.org \
--to=kuba@kernel.org \
--cc=amoulin@corp.free.fr \
--cc=borisp@nvidia.com \
--cc=john.fastabend@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=tariqt@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.