Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp853239pxk; Thu, 17 Sep 2020 19:08:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9doyt85BUdT8kKy8ts5dj5/KPOlMonWvpR2XSpDI9QUPeW1xiWbijGtdZeYjLJguS8Kxv X-Received: by 2002:a17:906:f11:: with SMTP id z17mr34724776eji.88.1600394879923; Thu, 17 Sep 2020 19:07:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600394879; cv=none; d=google.com; s=arc-20160816; b=Dk1hizQSudd/TntjHn6O/qC27+PlBgm2OfpIfiGZtoQpWCJEXifgOOU0P1d4gjJDja ORJiCADUDqg1tKOJ/yHeAJRIZkBLzPh+b1gEO4ArsXyM3w41Qo+4z9mGE7m+2s/DaH0o MgxjazvRKA3C/kaE4EIAUgoe2ZckNFl6aXhSYWxUrX4d1PTQiwFrM2CrG7/U2RtvLx4R nSzHAqzGkGSz6BHYJICjaaFAH5XDi+klxWihjWXO5AiCuH+p1OLdWaMJhzD5Y6dJ0mDN WzgZTNfyaGtdQJQ2+zHUlMNmOQhbblff2uOdgRtxS4OzYlO3nI5N7mHCiTreOjuRuCoL 7DsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=p/zH/hoXFY5P4DNw+g05ats3xiMQYQTc28MbRLFMGI0=; b=fwrj2QHFDs32Gi1tpWC4JDYKhHnK0vjbxg6NNSJVxJwSkj+5tSgXdyY/CrJreo/z+W gsuzl0DU+jlGsBf7jNk4LsshGIAX5Sxl8ZA0mivmtnqL+QHl6Lscy9WoogNFmj9P6P1+ hDiauy3pI3//r7hB49/eqzxL/I+In51NCJA0splZ26i2xt9p64O7T14KfWQzl/HlZXem 6c39aWqJhjS3//sRaM9+YwWipnA2mVIP/uWoKhFngGeyruU8DIQF71TWDw0H8LyK661m 767XxA7KvN65AntSuJvye7jHmUJE5/z03USkXauP9lVzk0k7x+lvJ67AdDznoSLSWxR/ IyRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gvLatr+v; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dn25si1108704edb.268.2020.09.17.19.07.37; Thu, 17 Sep 2020 19:07:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gvLatr+v; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727566AbgIRCFe (ORCPT + 99 others); Thu, 17 Sep 2020 22:05:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:53518 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727552AbgIRCFb (ORCPT ); Thu, 17 Sep 2020 22:05:31 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4468D238A0; Fri, 18 Sep 2020 02:05:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394729; bh=Ft50cF0MuhbQrKK3V7Zti76wllVU65zW4BxljG/MI9g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gvLatr+v4bB2NL+gUcQHW9hrQzThnOigpjyktc6KxddR29mAuRIQKfWQAcHIBwH1f Cz54MSuEc0wEtKgaiOYLxWjZtmcBDpeuWXquCoFsYl342J+2v9uobsTLmN+nk9gBdA OhtlDHAJK3QY6GWQu89uMjTzd0NvEFNFotI2lW2M= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Sergey Gorenko , Max Gurtovoy , Jason Gunthorpe , Sasha Levin , linux-rdma@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 211/330] IB/iser: Always check sig MR before putting it to the free pool Date: Thu, 17 Sep 2020 21:59:11 -0400 Message-Id: <20200918020110.2063155-211-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020110.2063155-1-sashal@kernel.org> References: <20200918020110.2063155-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sergey Gorenko [ Upstream commit 26e28deb813eed908cf31a6052870b6493ec0e86 ] libiscsi calls the check_protection transport handler only if SCSI-Respose is received. So, the handler is never called if iSCSI task is completed for some other reason like a timeout or error handling. And this behavior looks correct. But the iSER does not handle this case properly because it puts a non-checked signature MR to the free pool. Then the error occurs at reusing the MR because it is not allowed to invalidate a signature MR without checking. This commit adds an extra check to iser_unreg_mem_fastreg(), which is a part of the task cleanup flow. Now the signature MR is checked there if it is needed. Link: https://lore.kernel.org/r/20200325151210.1548-1-sergeygo@mellanox.com Signed-off-by: Sergey Gorenko Reviewed-by: Max Gurtovoy Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/ulp/iser/iser_memory.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/drivers/infiniband/ulp/iser/iser_memory.c b/drivers/infiniband/ulp/iser/iser_memory.c index 2cc89a9b9e9bb..ea8e611397a3b 100644 --- a/drivers/infiniband/ulp/iser/iser_memory.c +++ b/drivers/infiniband/ulp/iser/iser_memory.c @@ -292,12 +292,27 @@ void iser_unreg_mem_fastreg(struct iscsi_iser_task *iser_task, { struct iser_device *device = iser_task->iser_conn->ib_conn.device; struct iser_mem_reg *reg = &iser_task->rdma_reg[cmd_dir]; + struct iser_fr_desc *desc; + struct ib_mr_status mr_status; - if (!reg->mem_h) + desc = reg->mem_h; + if (!desc) return; - device->reg_ops->reg_desc_put(&iser_task->iser_conn->ib_conn, - reg->mem_h); + /* + * The signature MR cannot be invalidated and reused without checking. + * libiscsi calls the check_protection transport handler only if + * SCSI-Response is received. And the signature MR is not checked if + * the task is completed for some other reason like a timeout or error + * handling. That's why we must check the signature MR here before + * putting it to the free pool. + */ + if (unlikely(desc->sig_protected)) { + desc->sig_protected = false; + ib_check_mr_status(desc->rsc.sig_mr, IB_MR_CHECK_SIG_STATUS, + &mr_status); + } + device->reg_ops->reg_desc_put(&iser_task->iser_conn->ib_conn, desc); reg->mem_h = NULL; } -- 2.25.1