[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <9057206c-7173-4f1c-8ff7-ea5e2a29a66d@suse.de>
Date: Thu, 31 Jul 2025 18:05:33 +0200
From: Hannes Reinecke <hare@...e.de>
To: Olga Kornievskaia <okorniev@...hat.com>
Cc: chuck.lever@...cle.com, jlayton@...nel.org, trondmy@...merspace.com,
anna.schumaker@...cle.com, hch@....de, sagi@...mberg.me, kch@...dia.com,
davem@...emloft.net, edumazet@...gle.com, kuba@...nel.org,
pabeni@...hat.com, linux-nfs@...r.kernel.org,
linux-nvme@...ts.infradead.org, netdev@...r.kernel.org,
kernel-tls-handshake@...ts.linux.dev, neil@...wn.name, Dai.Ngo@...cle.com,
tom@...pey.com, horms@...nel.org, kbusch@...nel.org
Subject: Re: [PATCH 3/4] nvmet-tcp: fix handling of tls alerts
On 7/31/25 17:29, Olga Kornievskaia wrote:
> On Thu, Jul 31, 2025 at 2:10 AM Hannes Reinecke <hare@...e.de> wrote:
>>
>> On 7/30/25 22:08, Olga Kornievskaia wrote:
>>> Revert kvec msg iterator before trying to process a TLS alert
>>> when possible.
>>>
>>> In nvmet_tcp_try_recv_data(), it's assumed that no msg control
>>> message buffer is set prior to sock_recvmsg(). Hannes suggested
>>> that upon detecting that TLS control message is received log a
>>> message and error out. Left comments in the code for the future
>>> improvements.
>>>
>>> Fixes: a1c5dd8355b1 ("nvmet-tcp: control messages for recvmsg()")
>>> Suggested-by: Hannes Reinecke <hare@...e.de>
>>> Reviewed-by: Hannes Reinecky <hare@...u.de>
>>> Signed-off-by: Olga Kornievskaia <okorniev@...hat.com>
>>> ---
>>> drivers/nvme/target/tcp.c | 30 +++++++++++++++++++-----------
>>> 1 file changed, 19 insertions(+), 11 deletions(-)
>>>
>>> diff --git a/drivers/nvme/target/tcp.c b/drivers/nvme/target/tcp.c
>>> index 688033b88d38..055e420d3f2e 100644
>>> --- a/drivers/nvme/target/tcp.c
>>> +++ b/drivers/nvme/target/tcp.c
>>> @@ -1161,6 +1161,7 @@ static int nvmet_tcp_try_recv_pdu(struct nvmet_tcp_queue *queue)
>>> if (unlikely(len < 0))
>>> return len;
>>> if (queue->tls_pskid) {
>>> + iov_iter_revert(&msg.msg_iter, len);
>>> ret = nvmet_tcp_tls_record_ok(queue, &msg, cbuf);
>>> if (ret < 0)
>>> return ret;
>>> @@ -1217,19 +1218,28 @@ static void nvmet_tcp_prep_recv_ddgst(struct nvmet_tcp_cmd *cmd)
>>> static int nvmet_tcp_try_recv_data(struct nvmet_tcp_queue *queue)
>>> {
>>> struct nvmet_tcp_cmd *cmd = queue->cmd;
>>> - int len, ret;
>>> + int len;
>>>
>>> while (msg_data_left(&cmd->recv_msg)) {
>>> + /* to detect that we received a TlS alert, we assumed that
>>> + * cmg->recv_msg's control buffer is not setup. kTLS will
>>> + * return an error when no control buffer is set and
>>> + * non-tls-data payload is received.
>>> + */
>>> len = sock_recvmsg(cmd->queue->sock, &cmd->recv_msg,
>>> cmd->recv_msg.msg_flags);
>>> + if (cmd->recv_msg.msg_flags & MSG_CTRUNC) {
>>> + if (len == 0 || len == -EIO) {
>>> + pr_err("queue %d: unhandled control message\n",
>>> + queue->idx);
>>> + /* note that unconsumed TLS control message such
>>> + * as TLS alert is still on the socket.
>>> + */
>>
>> Hmm. Will it get cleared when we close the socket?
>
> If the socket is closed then any data on that socket would be freed.
>
>> Or shouldn't we rather introduce proper cmsg handling?
>
> That would be what I have originally proposed (I know that was on the
> private list). But yes, we can setup a dedicated kvec to receive the
> TLS control message once its been detected and then call
> nvme_tcp_tls_record_ok().
>
> Let me know if proper cmsg handling is what's desired for this patch.
>
>> (If we do, we'll need it to do on the host side, too)
>
No, let's delegate that to a next step. My main concern is that
data on the socket is freed upon closing (ie on reconnect).
If that's the case we should leave it for now.
There is talk to handle TLS new session ticket messages, which probably
will require some evaluation of TLS messages and will most certainly
require the updated TLS Alert handling.
Cheers,
Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
hare@...e.de +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Powered by blists - more mailing lists