Linux-RDMA Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] IB/srp: Never use immediate data if it is disabled by a user
@ 2020-01-15 13:30 Sergey Gorenko
  2020-01-15 16:08 ` Bart Van Assche
  2020-01-15 20:38 ` Jason Gunthorpe
  0 siblings, 2 replies; 3+ messages in thread
From: Sergey Gorenko @ 2020-01-15 13:30 UTC (permalink / raw)
  To: bvanassche; +Cc: linux-rdma, Sergey Gorenko

Some SRP targets that do not support specification SRP-2, put
the garbage to the reserved bits of the SRP login response.
The problem was not detected for a long time because the SRP
initiator ignored those bits. But now one of them is used as
SRP_LOGIN_RSP_IMMED_SUPP. And it causes a critical error on
the target when the initiator sends immediate data.

The ib_srp module has a use_imm_date parameter to enable or
disable immediate data manually. But it does not help in the above
case, because use_imm_date is ignored at handling the SRP login
response. The problem is definitely caused by a bug on the target
side, but the initiator's behavior also does not look correct.
The initiator should not use immediate data if use_imm_date is
disabled by a user.

This commit adds an additional checking of use_imm_date at
the handling of SRP login response to avoid unexpected use of
immediate data.

Fixes: commit 882981f4a411 ("RDMA/srp: Add support for immediate data")
Signed-off-by: Sergey Gorenko <sergeygo@mellanox.com>
---
 drivers/infiniband/ulp/srp/ib_srp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index b7f7a5f7bd98..cd1181c39ed2 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -2546,7 +2546,8 @@ static void srp_cm_rep_handler(struct ib_cm_id *cm_id,
 	if (lrsp->opcode == SRP_LOGIN_RSP) {
 		ch->max_ti_iu_len = be32_to_cpu(lrsp->max_ti_iu_len);
 		ch->req_lim       = be32_to_cpu(lrsp->req_lim_delta);
-		ch->use_imm_data  = lrsp->rsp_flags & SRP_LOGIN_RSP_IMMED_SUPP;
+		ch->use_imm_data  = srp_use_imm_data &&
+			(lrsp->rsp_flags & SRP_LOGIN_RSP_IMMED_SUPP);
 		ch->max_it_iu_len = srp_max_it_iu_len(target->cmd_sg_cnt,
 						      ch->use_imm_data,
 						      target->max_it_iu_size);
-- 
2.21.0


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

* Re: [PATCH] IB/srp: Never use immediate data if it is disabled by a user
  2020-01-15 13:30 [PATCH] IB/srp: Never use immediate data if it is disabled by a user Sergey Gorenko
@ 2020-01-15 16:08 ` Bart Van Assche
  2020-01-15 20:38 ` Jason Gunthorpe
  1 sibling, 0 replies; 3+ messages in thread
From: Bart Van Assche @ 2020-01-15 16:08 UTC (permalink / raw)
  To: Sergey Gorenko; +Cc: linux-rdma

On 1/15/20 5:30 AM, Sergey Gorenko wrote:
> Some SRP targets that do not support specification SRP-2, put
> the garbage to the reserved bits of the SRP login response.
> The problem was not detected for a long time because the SRP
> initiator ignored those bits. But now one of them is used as
> SRP_LOGIN_RSP_IMMED_SUPP. And it causes a critical error on
> the target when the initiator sends immediate data.
> 
> The ib_srp module has a use_imm_date parameter to enable or
> disable immediate data manually. But it does not help in the above
> case, because use_imm_date is ignored at handling the SRP login
> response. The problem is definitely caused by a bug on the target
> side, but the initiator's behavior also does not look correct.
> The initiator should not use immediate data if use_imm_date is
> disabled by a user.
> 
> This commit adds an additional checking of use_imm_date at
> the handling of SRP login response to avoid unexpected use of
> immediate data.

Reviewed-by: Bart Van Assche <bvanassche@acm.org>

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

* Re: [PATCH] IB/srp: Never use immediate data if it is disabled by a user
  2020-01-15 13:30 [PATCH] IB/srp: Never use immediate data if it is disabled by a user Sergey Gorenko
  2020-01-15 16:08 ` Bart Van Assche
@ 2020-01-15 20:38 ` Jason Gunthorpe
  1 sibling, 0 replies; 3+ messages in thread
From: Jason Gunthorpe @ 2020-01-15 20:38 UTC (permalink / raw)
  To: Sergey Gorenko; +Cc: bvanassche, linux-rdma

On Wed, Jan 15, 2020 at 01:30:55PM +0000, Sergey Gorenko wrote:
> Some SRP targets that do not support specification SRP-2, put
> the garbage to the reserved bits of the SRP login response.
> The problem was not detected for a long time because the SRP
> initiator ignored those bits. But now one of them is used as
> SRP_LOGIN_RSP_IMMED_SUPP. And it causes a critical error on
> the target when the initiator sends immediate data.
> 
> The ib_srp module has a use_imm_date parameter to enable or
> disable immediate data manually. But it does not help in the above
> case, because use_imm_date is ignored at handling the SRP login
> response. The problem is definitely caused by a bug on the target
> side, but the initiator's behavior also does not look correct.
> The initiator should not use immediate data if use_imm_date is
> disabled by a user.
> 
> This commit adds an additional checking of use_imm_date at
> the handling of SRP login response to avoid unexpected use of
> immediate data.
> 
> Fixes: commit 882981f4a411 ("RDMA/srp: Add support for immediate data")
> Signed-off-by: Sergey Gorenko <sergeygo@mellanox.com>
> Reviewed-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  drivers/infiniband/ulp/srp/ib_srp.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

Applied to for-next, thanks

Jason

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

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-15 13:30 [PATCH] IB/srp: Never use immediate data if it is disabled by a user Sergey Gorenko
2020-01-15 16:08 ` Bart Van Assche
2020-01-15 20:38 ` Jason Gunthorpe

Linux-RDMA Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-rdma/0 linux-rdma/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-rdma linux-rdma/ https://lore.kernel.org/linux-rdma \
		linux-rdma@vger.kernel.org
	public-inbox-index linux-rdma

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-rdma


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git