Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5613230img; Wed, 27 Mar 2019 11:43:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqz24D16BZLK1jsWcVq3KcLryr91heut9RqO48knVIA9a9AT79k022UhsWUdFKn227Lkyi0f X-Received: by 2002:a17:902:b788:: with SMTP id e8mr28230434pls.339.1553712193994; Wed, 27 Mar 2019 11:43:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553712193; cv=none; d=google.com; s=arc-20160816; b=Mx2rFYhHaXYQiEjO2PiRFvEbrocqE7bmIOVacrj+j7/UTbGRvygHL/1t7DxgeXuS6k Vcz9mQ9Za5q4mqiEdBmDXMX4Iji1dFpFGkh8kqiKtuSbIDrC7U1Vda9Yqwp8iFVz5ZJQ Lf3RHp2ucVkE7DPRYAuHCb5loYEP3G2if26FNs7pZeojBt6/yhbEf0zUA7qR0ce5nJ3J QDzeTFmZqhwJqSaauylt/cxxpXD4DO6iFNoMpgdEPM22wu9eCBNlQQsrXxtcrqGzghGW bvOX/IayY+tkPxcM/qqplAm1ZN2PXPBrOa8YyHSya52OWYy+K4rF8wm+cSqWrd/yL9hT 4mIg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=mzDZS100h/RukhvrSCJ4fXU0rsywxB0cZ+3FoPngOYg=; b=wPAwaUc6Vyl9Pl0TfCoPePyr19gEkuwmmI6vUiFWMLkYi6VPf9YreQZqRe+XfxRjVh 9JAwCG9c9sUHeGYebH1whNSYi+kCI9n8lBO0BmjmVn2+T6I+dAMLvKe8a02QqWfDfoWo zObHG23HlxGAeRanWG/Z+9gMdx/I3za9D/X4vGhZlVFL2uz/Mg3rdtEVinbAMu2XvI6P 73ztj2cijMB2RFRgIzbxuVitFOLl8RFGqEzb+HYhm+2tEw6ycNVRzekql+PkYGjUEfhS I8ZDrbaXRJ4V14qDSaOtahqeLYU3uoOxiwNphoD4CYtojR34SWQx7G3M2E5kNGISsiry ZwvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mGK5C4cY; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e20si18331108pfi.237.2019.03.27.11.42.58; Wed, 27 Mar 2019 11:43:13 -0700 (PDT) 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=mGK5C4cY; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391569AbfC0Sld (ORCPT + 99 others); Wed, 27 Mar 2019 14:41:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:40480 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403852AbfC0SWW (ORCPT ); Wed, 27 Mar 2019 14:22:22 -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 D3ED62070B; Wed, 27 Mar 2019 18:22:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553710941; bh=M8BwuojB0quDlV38YY1jenayg8hOXZcfwvK7yLTmiGw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mGK5C4cY7zl9J+vP5BWPLsDoEMo8VogVTyjmb+AoodNe5EYK9TWT7XFsLrv9DfylI tu3iqyFy+1qkdFvxBxp9/sTiJh8Yf3UJnF6fkw+cuy9xzfRzsQZ0exwrgMiIbS9eUl od8A4HFe1Kt0G7KYFsneV+QjCDXcRAPV8MXTEmIw= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Raju Rangoju , Jason Gunthorpe , Sasha Levin , linux-rdma@vger.kernel.org Subject: [PATCH AUTOSEL 4.9 56/87] iw_cxgb4: fix srqidx leak during connection abort Date: Wed, 27 Mar 2019 14:20:09 -0400 Message-Id: <20190327182040.17444-56-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327182040.17444-1-sashal@kernel.org> References: <20190327182040.17444-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Raju Rangoju [ Upstream commit f368ff188ae4b3ef6f740a15999ea0373261b619 ] When an application aborts the connection by moving QP from RTS to ERROR, then iw_cxgb4's modify_rc_qp() RTS->ERROR logic sets the *srqidxp to 0 via t4_set_wq_in_error(&qhp->wq, 0), and aborts the connection by calling c4iw_ep_disconnect(). c4iw_ep_disconnect() does the following: 1. sends up a close_complete_upcall(ep, -ECONNRESET) to libcxgb4. 2. sends abort request CPL to hw. But, since the close_complete_upcall() is sent before sending the ABORT_REQ to hw, libcxgb4 would fail to release the srqidx if the connection holds one. Because, the srqidx is passed up to libcxgb4 only after corresponding ABORT_RPL is processed by kernel in abort_rpl(). This patch handle the corner-case by moving the call to close_complete_upcall() from c4iw_ep_disconnect() to abort_rpl(). So that libcxgb4 is notified about the -ECONNRESET only after abort_rpl(), and libcxgb4 can relinquish the srqidx properly. Signed-off-by: Raju Rangoju Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/hw/cxgb4/cm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c index dd18b74cd01d..a2322b2dbd82 100644 --- a/drivers/infiniband/hw/cxgb4/cm.c +++ b/drivers/infiniband/hw/cxgb4/cm.c @@ -1872,8 +1872,10 @@ static int abort_rpl(struct c4iw_dev *dev, struct sk_buff *skb) } mutex_unlock(&ep->com.mutex); - if (release) + if (release) { + close_complete_upcall(ep, -ECONNRESET); release_ep_resources(ep); + } c4iw_put_ep(&ep->com); return 0; } @@ -3567,7 +3569,6 @@ int c4iw_ep_disconnect(struct c4iw_ep *ep, int abrupt, gfp_t gfp) if (close) { if (abrupt) { set_bit(EP_DISC_ABORT, &ep->com.history); - close_complete_upcall(ep, -ECONNRESET); ret = send_abort(ep); } else { set_bit(EP_DISC_CLOSE, &ep->com.history); -- 2.19.1