Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp683972ybv; Thu, 13 Feb 2020 07:43:24 -0800 (PST) X-Google-Smtp-Source: APXvYqxN9rIb37gqzOjXqrO9cspdu2XAu3nWia5VdmOgjka/IUdsEOjE8m1u01P1VtR7Q+3G3pAs X-Received: by 2002:a05:6830:15c2:: with SMTP id j2mr3116324otr.351.1581608604524; Thu, 13 Feb 2020 07:43:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581608604; cv=none; d=google.com; s=arc-20160816; b=LBjk59CvemYiST3O3fy21jcywU9b344HdzU8v1GcGtHDlFzLfJ2L9eotgU0ZuqWqsS DgJ5cRNlz3+O9IWWTOXQoCMRQh+iEc+Hk/fbh301lcjcafUkbLZvkfcbGqECRj/mJBa7 VRGANtChHkaZBfkM1Mz1yeXydm+xzfx+fzLX97xZAjbs0mo+Vxs1MhwZZKX7wmIgvwnY 8dUA0fceqqAvpNiylzPSVRkvHlIuw2yEYVm3jmkJPCOvBXVOGa9c6VMumpmMGYW342c1 ahTbFBCegwmOy2u9FKNRh60PdmnAkUNeVp23Xu/BUMRi5t5CVZ3EeWQh5U9YJqEq93hf hOOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0O90YUAVs2PTk2w4z9vmk3R3IUCzhfbzoat5CtTitDk=; b=OCADIKLgBmx3M+4X7X/eYe8pW8SjaBp6bt5qluQh4yTMv/zoooKT6Obga5/NZon3Aj 8g18ec91DocJN4/GDwKG8h+q6hz0oe8/daWLsTTbnSMm64dVh7HFkrNEdTjJLE0l+CJ4 suJ9CSSfX7wJXKYpuGPlEGIXn2ZxXnKaCbyqZidYcXfIhavQ/iF+DNLovUUI3QhA04Sa fSS8pR0UTwmzXRKpaoNaJyi5dQ+FHWIzIqdBAjS5B6vZ77r1MBF4CQO00vOe618WY5Bg NT/4xrZdjVEXAMv1p0D9ohMJNOFPrd1EGN5oeqfmSmW/wY3LO0qBIVMJMlj5sYNpPEMy St8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fYoyb+cf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r8si1272242ota.288.2020.02.13.07.43.12; Thu, 13 Feb 2020 07:43:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fYoyb+cf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729162AbgBMPnK (ORCPT + 99 others); Thu, 13 Feb 2020 10:43:10 -0500 Received: from mail.kernel.org ([198.145.29.99]:53916 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728332AbgBMP2A (ORCPT ); Thu, 13 Feb 2020 10:28:00 -0500 Received: from localhost (unknown [104.132.1.104]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4E56F24677; Thu, 13 Feb 2020 15:28:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581607680; bh=JlPOFG2Dfl0ScRZaq+loHRP1Q0SDK9iFvbCKI1AeBV8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fYoyb+cf0qrxqL8kC4nRacuN2hulHYjy3kkiK31VDRZkPkO9iTpsCaLIyw+o/NgMH b0Sr09Bh9sR9dnwPR3d9vDBWXi76q/p7oVTcOoKnOkskvSOceOTTvrTpwby5CZz5ME AE6XOJuMvPOlHBOHPvbO9fldOST7oyZ5v0TxuSXk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sergey Gorenko , Bart Van Assche , Jason Gunthorpe Subject: [PATCH 5.5 002/120] IB/srp: Never use immediate data if it is disabled by a user Date: Thu, 13 Feb 2020 07:19:58 -0800 Message-Id: <20200213151901.999623265@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200213151901.039700531@linuxfoundation.org> References: <20200213151901.039700531@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sergey Gorenko commit 0fbb37dd82998b5c83355997b3bdba2806968ac7 upstream. 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: 882981f4a411 ("RDMA/srp: Add support for immediate data") Link: https://lore.kernel.org/r/20200115133055.30232-1-sergeygo@mellanox.com Signed-off-by: Sergey Gorenko Reviewed-by: Bart Van Assche Signed-off-by: Jason Gunthorpe Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/ulp/srp/ib_srp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- 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 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);