From: Stefan Metzmacher <metze@samba.org>
To: David Howells <dhowells@redhat.com>, Steve French <smfrench@gmail.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
Shyam Prasad N <nspmangalore@gmail.com>,
Rohith Surabattula <rohiths.msft@gmail.com>,
Tom Talpey <tom@talpey.com>,
Christoph Hellwig <hch@infradead.org>,
Matthew Wilcox <willy@infradead.org>,
Jeff Layton <jlayton@kernel.org>,
linux-cifs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org, Long Li <longli@microsoft.com>,
Namjae Jeon <linkinjeon@kernel.org>
Subject: Re: [PATCH 11/12] cifs: Fix problem with encrypted RDMA data read
Date: Wed, 1 Feb 2023 15:52:59 +0100 [thread overview]
Message-ID: <4a43598d-51f0-b7bb-575a-d93f7879741f@samba.org> (raw)
In-Reply-To: <be4dfc12-5593-e93a-3f78-638ee8ea9ad8@samba.org>
Am 01.02.23 um 15:05 schrieb Stefan Metzmacher:
> Am 31.01.23 um 19:28 schrieb David Howells:
>> When the cifs client is talking to the ksmbd server by RDMA and the ksmbd
>> server has "smb3 encryption = yes" in its config file, the normal PDU
>> stream is encrypted, but the directly-delivered data isn't in the stream
>> (and isn't encrypted), but is rather delivered by DDP/RDMA packets (at
>> least with IWarp).
>>
>> Currently, the direct delivery fails with:
>>
>> buf can not contain only a part of read data
>> WARNING: CPU: 0 PID: 4619 at fs/cifs/smb2ops.c:4731 handle_read_data+0x393/0x405
>> ...
>> RIP: 0010:handle_read_data+0x393/0x405
>> ...
>> smb3_handle_read_data+0x30/0x37
>> receive_encrypted_standard+0x141/0x224
>> cifs_demultiplex_thread+0x21a/0x63b
>> kthread+0xe7/0xef
>> ret_from_fork+0x22/0x30
>>
>> The problem apparently stemming from the fact that it's trying to manage
>> the decryption, but the data isn't in the smallbuf, the bigbuf or the page
>> array).
>>
>> This can be fixed simply by inserting an extra case into handle_read_data()
>> that checks to see if use_rdma_mr is true, and if it is, just setting
>> rdata->got_bytes to the length of data delivered and allowing normal
>> continuation.
>>
>> This can be seen in an IWarp packet trace. With the upstream code, it does
>> a DDP/RDMA packet, which produces the warning above and then retries,
>> retrieving the data inline, spread across several SMBDirect messages that
>> get glued together into a single PDU. With the patch applied, only the
>> DDP/RDMA packet is seen.
>>
>> Note that this doesn't happen if the server isn't told to encrypt stuff and
>> it does also happen with softRoCE.
>>
>> Signed-off-by: David Howells <dhowells@redhat.com>
>> cc: Steve French <smfrench@gmail.com>
>> cc: Tom Talpey <tom@talpey.com>
>> cc: Long Li <longli@microsoft.com>
>> cc: Namjae Jeon <linkinjeon@kernel.org>
>> cc: Stefan Metzmacher <metze@samba.org>
>> cc: linux-cifs@vger.kernel.org
>>
>> Link: https://lore.kernel.org/r/166855224228.1998592.2212551359609792175.stgit@warthog.procyon.org.uk/ # v1
>> ---
>> fs/cifs/smb2ops.c | 3 +++
>> 1 file changed, 3 insertions(+)
>>
>> diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
>> index cea578a45ed8..73b66ac86abf 100644
>> --- a/fs/cifs/smb2ops.c
>> +++ b/fs/cifs/smb2ops.c
>> @@ -4733,6 +4733,9 @@ handle_read_data(struct TCP_Server_Info *server, struct mid_q_entry *mid,
>> if (length < 0)
>> return length;
>> rdata->got_bytes = data_len;
>> + } else if (use_rdma_mr) {
>> + /* The data was delivered directly by RDMA. */
>> + rdata->got_bytes = data_len;
>
> I actually don't understand why this would only be a problem with encryption.
>
> I guess there's much more needed and data_offset should most likely be
> ignored completely in the rdma offload case. So I'd guess its just luck
> that we don't trigger the below warning/error more often.
I guess it might be related to smb3_handle_read_data passing
server->pdu_size to handle_read_data(), while server->pdu_size is
the outer size of the transform and not the size of the decrypted pdu.
Maybe receive_encrypted_standard() needs to reset server->pdu_size
during this:
if (mid_entry && mid_entry->handle)
ret = mid_entry->handle(server, mid_entry);
else
ret = cifs_handle_standard(server, mid_entry);
But this code is so overly complex, that's way to hard to understand...
next prev parent reply other threads:[~2023-02-01 14:53 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-31 18:28 [PATCH 00/12] smb3: Use iov_iters down to the network transport and fix DIO page pinning David Howells
2023-01-31 18:28 ` [PATCH 01/12] netfs: Add a function to extract a UBUF or IOVEC into a BVEC iterator David Howells
2023-01-31 18:28 ` [PATCH 02/12] netfs: Add a function to extract an iterator into a scatterlist David Howells
2023-01-31 18:28 ` [PATCH 03/12] cifs: Implement splice_read to pass down ITER_BVEC not ITER_PIPE David Howells
2023-02-01 13:35 ` Christoph Hellwig
2023-01-31 18:28 ` [PATCH 04/12] cifs: Add a function to build an RDMA SGE list from an iterator David Howells
2023-01-31 18:28 ` [PATCH 05/12] cifs: Add a function to Hash the contents of " David Howells
2023-02-01 8:52 ` Herbert Xu
2023-02-01 14:36 ` David Howells
2023-02-02 0:55 ` Herbert Xu
2023-02-03 21:00 ` David Howells
2023-01-31 18:28 ` [PATCH 06/12] cifs: Add some helper functions David Howells
2023-01-31 18:28 ` [PATCH 07/12] cifs: Add a function to read into an iter from a socket David Howells
2023-01-31 18:28 ` [PATCH 09/12] cifs: Build the RDMA SGE list directly from an iterator David Howells
2023-01-31 18:28 ` [PATCH 10/12] cifs: Remove unused code David Howells
2023-01-31 18:28 ` [PATCH 11/12] cifs: Fix problem with encrypted RDMA data read David Howells
2023-02-01 13:36 ` Christoph Hellwig
2023-02-01 14:00 ` Stefan Metzmacher
2023-02-01 14:05 ` Stefan Metzmacher
2023-02-01 14:52 ` Stefan Metzmacher [this message]
2023-01-31 18:28 ` [PATCH 12/12] cifs: DIO to/from KVEC-type iterators should now work David Howells
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=4a43598d-51f0-b7bb-575a-d93f7879741f@samba.org \
--to=metze@samba.org \
--cc=dhowells@redhat.com \
--cc=hch@infradead.org \
--cc=jlayton@kernel.org \
--cc=linkinjeon@kernel.org \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=longli@microsoft.com \
--cc=nspmangalore@gmail.com \
--cc=rohiths.msft@gmail.com \
--cc=smfrench@gmail.com \
--cc=tom@talpey.com \
--cc=viro@zeniv.linux.org.uk \
--cc=willy@infradead.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox