All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH] nvmet_tcp: fix header digest verification
       [not found] <20211019113307.31852-1-amit.engel@dell.com>
@ 2021-10-19 12:18 ` Sagi Grimberg
  2021-10-20 15:43   ` Engel, Amit
  0 siblings, 1 reply; 8+ messages in thread
From: Sagi Grimberg @ 2021-10-19 12:18 UTC (permalink / raw)
  To: Amit Engel, linux-nvme, hch


> pass the correct length to nvmet_tcp_hdgst.
> when verify_hdgst, need to pass pdu header len.
> This fixes a wrong behaviour where
> header digest verification pass although digest is wrong

Amit, can you describe what you mean here?
what is wrong about the digest?

What is currently passed in len is queue->offset, which is
the temporary offset from the pdu, which is equal to hdr->hlen
because we verify the digest right after we finish reading the PDU
header.

> 
> Signed-off-by: Amit Engel <amit.engel@dell.com>
> ---
>   drivers/nvme/target/tcp.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/nvme/target/tcp.c b/drivers/nvme/target/tcp.c
> index 6eb0b3153477..954c27a94561 100644
> --- a/drivers/nvme/target/tcp.c
> +++ b/drivers/nvme/target/tcp.c
> @@ -268,7 +268,7 @@ static int nvmet_tcp_verify_hdgst(struct nvmet_tcp_queue *queue,
>   	}
>   
>   	recv_digest = *(__le32 *)(pdu + hdr->hlen);
> -	nvmet_tcp_hdgst(queue->rcv_hash, pdu, len);
> +	nvmet_tcp_hdgst(queue->rcv_hash, pdu, hdr->hlen);

If at all, the caller should pass hdr->hlen and keep this generic.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [PATCH] nvmet_tcp: fix header digest verification
  2021-10-19 12:18 ` [PATCH] nvmet_tcp: fix header digest verification Sagi Grimberg
@ 2021-10-20 15:43   ` Engel, Amit
  2021-10-20 17:53     ` Sagi Grimberg
  0 siblings, 1 reply; 8+ messages in thread
From: Engel, Amit @ 2021-10-20 15:43 UTC (permalink / raw)
  To: Sagi Grimberg, linux-nvme, hch

One of our tests found that 
With the current code,
recv_digest == exp_digest even if the pdu header digest is being modified (synthetically)
For example:
In case that pdu header digest is changed to 0xffffffff, recv == exp == 0xfffffff, and nvmet_tcp_verify_hdgst returns 0 - which is wrong


Internal Use - Confidential

-----Original Message-----
From: Sagi Grimberg <sagi@grimberg.me> 
Sent: Tuesday, October 19, 2021 3:19 PM
To: Engel, Amit; linux-nvme@lists.infradead.org; hch@lst.de
Subject: Re: [PATCH] nvmet_tcp: fix header digest verification


[EXTERNAL EMAIL] 


> pass the correct length to nvmet_tcp_hdgst.
> when verify_hdgst, need to pass pdu header len.
> This fixes a wrong behaviour where
> header digest verification pass although digest is wrong

Amit, can you describe what you mean here?
what is wrong about the digest?

What is currently passed in len is queue->offset, which is the temporary offset from the pdu, which is equal to hdr->hlen because we verify the digest right after we finish reading the PDU header.

> 
> Signed-off-by: Amit Engel <amit.engel@dell.com>
> ---
>   drivers/nvme/target/tcp.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/nvme/target/tcp.c b/drivers/nvme/target/tcp.c 
> index 6eb0b3153477..954c27a94561 100644
> --- a/drivers/nvme/target/tcp.c
> +++ b/drivers/nvme/target/tcp.c
> @@ -268,7 +268,7 @@ static int nvmet_tcp_verify_hdgst(struct nvmet_tcp_queue *queue,
>   	}
>   
>   	recv_digest = *(__le32 *)(pdu + hdr->hlen);
> -	nvmet_tcp_hdgst(queue->rcv_hash, pdu, len);
> +	nvmet_tcp_hdgst(queue->rcv_hash, pdu, hdr->hlen);

If at all, the caller should pass hdr->hlen and keep this generic.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] nvmet_tcp: fix header digest verification
  2021-10-20 15:43   ` Engel, Amit
@ 2021-10-20 17:53     ` Sagi Grimberg
  2021-10-25  8:47       ` Engel, Amit
  0 siblings, 1 reply; 8+ messages in thread
From: Sagi Grimberg @ 2021-10-20 17:53 UTC (permalink / raw)
  To: Engel, Amit, linux-nvme, hch


> One of our tests found that
> With the current code,
> recv_digest == exp_digest even if the pdu header digest is being modified (synthetically)
> For example:
> In case that pdu header digest is changed to 0xffffffff, recv == exp == 0xfffffff, and nvmet_tcp_verify_hdgst returns 0 - which is wrong

Not sure I follow. Can you describe in which case the passed offset !=
hdr->hlen?


> Internal Use - Confidential

Is this confidential?


^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [PATCH] nvmet_tcp: fix header digest verification
  2021-10-20 17:53     ` Sagi Grimberg
@ 2021-10-25  8:47       ` Engel, Amit
  2021-10-26 15:34         ` Sagi Grimberg
  0 siblings, 1 reply; 8+ messages in thread
From: Engel, Amit @ 2021-10-25  8:47 UTC (permalink / raw)
  To: Sagi Grimberg, linux-nvme, hch

In nvmet_tcp_try_recv_pdu:
1. After kernel_recvmsg, 'queue->offset' is equal to 'sizeof(struct nvme_tcp_hdr)'

2. update queue->left = hdr->hlen - queue->offset + hdgst and 'goto recv'

3. after recvmsg , the offset is greater than the digest.

So , In this case offset != hdr->hlen 

This will lead to nvmet_tcp_verify_hdgst to always pass, which 

Thanks
Amit


Internal Use - Confidential

-----Original Message-----
From: Sagi Grimberg <sagi@grimberg.me> 
Sent: Wednesday, October 20, 2021 8:53 PM
To: Engel, Amit; linux-nvme@lists.infradead.org; hch@lst.de
Subject: Re: [PATCH] nvmet_tcp: fix header digest verification


[EXTERNAL EMAIL] 


> One of our tests found that
> With the current code,
> recv_digest == exp_digest even if the pdu header digest is being 
> modified (synthetically) For example:
> In case that pdu header digest is changed to 0xffffffff, recv == exp 
> == 0xfffffff, and nvmet_tcp_verify_hdgst returns 0 - which is wrong

Not sure I follow. Can you describe in which case the passed offset !=
hdr->hlen?


> Internal Use - Confidential

Is this confidential?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] nvmet_tcp: fix header digest verification
  2021-10-25  8:47       ` Engel, Amit
@ 2021-10-26 15:34         ` Sagi Grimberg
  2021-10-27  6:50           ` Engel, Amit
  0 siblings, 1 reply; 8+ messages in thread
From: Sagi Grimberg @ 2021-10-26 15:34 UTC (permalink / raw)
  To: Engel, Amit, linux-nvme, hch


> In nvmet_tcp_try_recv_pdu:
> 1. After kernel_recvmsg, 'queue->offset' is equal to 'sizeof(struct nvme_tcp_hdr)'
> 
> 2. update queue->left = hdr->hlen - queue->offset + hdgst and 'goto recv'
> 
> 3. after recvmsg , the offset is greater than the digest.
> 
> So , In this case offset != hdr->hlen
> 
> This will lead to nvmet_tcp_verify_hdgst to always pass, which

I see, so the patch should modify the call-site to
nvmet_tcp_verify_hdgst to pass in hdr->hlen.

> 
> Thanks
> Amit
> 
> 
> Internal Use - Confidential

You should remove this footer from your emails to the public
mailing list...


^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [PATCH] nvmet_tcp: fix header digest verification
  2021-10-26 15:34         ` Sagi Grimberg
@ 2021-10-27  6:50           ` Engel, Amit
  0 siblings, 0 replies; 8+ messages in thread
From: Engel, Amit @ 2021-10-27  6:50 UTC (permalink / raw)
  To: Sagi Grimberg, linux-nvme, hch

Thank you Sagi. I just sent the patch

Amit

-----Original Message-----
From: Sagi Grimberg <sagi@grimberg.me> 
Sent: Tuesday, October 26, 2021 6:35 PM
To: Engel, Amit; linux-nvme@lists.infradead.org; hch@lst.de
Subject: Re: [PATCH] nvmet_tcp: fix header digest verification


[EXTERNAL EMAIL] 


> In nvmet_tcp_try_recv_pdu:
> 1. After kernel_recvmsg, 'queue->offset' is equal to 'sizeof(struct nvme_tcp_hdr)'
> 
> 2. update queue->left = hdr->hlen - queue->offset + hdgst and 'goto recv'
> 
> 3. after recvmsg , the offset is greater than the digest.
> 
> So , In this case offset != hdr->hlen
> 
> This will lead to nvmet_tcp_verify_hdgst to always pass, which

I see, so the patch should modify the call-site to nvmet_tcp_verify_hdgst to pass in hdr->hlen.

> 
> Thanks
> Amit
> 
> 
> Internal Use - Confidential

You should remove this footer from your emails to the public mailing list...

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] nvmet_tcp: fix header digest verification
       [not found] <20211027064927.20452-1-amit.engel@dell.com>
  2021-10-27  7:09 ` Sagi Grimberg
@ 2021-10-27  7:21 ` Christoph Hellwig
  1 sibling, 0 replies; 8+ messages in thread
From: Christoph Hellwig @ 2021-10-27  7:21 UTC (permalink / raw)
  To: Amit Engel; +Cc: linux-nvme, sagi, hch, amit.engel@dell.com--from=amit.engel

Thanks,

applied to nvme-5.15.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] nvmet_tcp: fix header digest verification
       [not found] <20211027064927.20452-1-amit.engel@dell.com>
@ 2021-10-27  7:09 ` Sagi Grimberg
  2021-10-27  7:21 ` Christoph Hellwig
  1 sibling, 0 replies; 8+ messages in thread
From: Sagi Grimberg @ 2021-10-27  7:09 UTC (permalink / raw)
  To: Amit Engel, linux-nvme, hch

Reviewed-by: Sagi Grimberg <sagi@grimberg.me>


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-10-27  7:21 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20211019113307.31852-1-amit.engel@dell.com>
2021-10-19 12:18 ` [PATCH] nvmet_tcp: fix header digest verification Sagi Grimberg
2021-10-20 15:43   ` Engel, Amit
2021-10-20 17:53     ` Sagi Grimberg
2021-10-25  8:47       ` Engel, Amit
2021-10-26 15:34         ` Sagi Grimberg
2021-10-27  6:50           ` Engel, Amit
     [not found] <20211027064927.20452-1-amit.engel@dell.com>
2021-10-27  7:09 ` Sagi Grimberg
2021-10-27  7:21 ` Christoph Hellwig

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.