Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1023456yba; Thu, 4 Apr 2019 02:39:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqz7SdoEgmw+Vp5taFoWQ9XRM+pv8wMImr4KSzdOqQXjZ0oPMahfdvY0fjoa6N+G4qVSHj/x X-Received: by 2002:a62:6402:: with SMTP id y2mr4721705pfb.194.1554370771806; Thu, 04 Apr 2019 02:39:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554370771; cv=none; d=google.com; s=arc-20160816; b=FrFfep8IIlajTwgNefqKw1//9R2UKLXNkNYmP2Iz+0K4pvcXIwDLgW2mRSrNEvSw1R wR7+NAXPz9APsRnnGHEIDq0V7ifCwwmzcW68W72atc8VsaJkTdSeB49pTs5EG7GV0Cd0 YXDY9d9RZHFPtlBTU+O6AG7geRB5sCcbmSIPbRAF8PnzAmRDIgYYhgYNoPFyg1hgRDae IlA87fMVaFD+IzbS+LzIPTFS12H4SVQLRG911EVVHmaa0/RIjysWZuoXZ/IHMuUMTMNe ftfJnvuF53e/IfCmswc6gtSksPdpeKUDO4T5C5HqGtzXl6M199NhSWwhcwjB9Te8kgFW ZS3A== 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=w/BcfTV5uQTSKgEt4Boj9nkKX5myvzywlSuTqOxurr8=; b=BbVRl97gvlK61ASqGJkhuOaeNkiseKy0btvmek4qvHbchs0cKnitDsuf5PLMPIumeM dxxDdmsN5qbp2PzunJuST7H9Gfl0M7rp4J0vbMTperhBV2/MZkH5EJEFXTlJfrV/Id1X ECvdMUPb9p8CHWt7B4jQ4Qlahzk838yaD/XmfRkW8QLm88h0ojKmVNKIt4z0z3bnPhwu 0itDWVb3/uM1P7plH6YFhcNEcP54pH8UAL64PPm6dPGTJw42K3SPDo2fJpoDErjSo3BX YnlxiyT5NU6ZXYXKkjYRTdxSkVTYzQBWzMyFy4g32GVkRDITNv6H8qWsjYyA8qkKdb1Y W6iA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GqRM+MpP; 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 cm17si17185826plb.139.2019.04.04.02.39.16; Thu, 04 Apr 2019 02:39:31 -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=GqRM+MpP; 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 S1731914AbfDDJEN (ORCPT + 99 others); Thu, 4 Apr 2019 05:04:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:41864 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730622AbfDDJEI (ORCPT ); Thu, 4 Apr 2019 05:04:08 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 A60B52147C; Thu, 4 Apr 2019 09:04:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554368648; bh=futYYTW+fd3gv41rJ3uZ+KMoM75gHrjnlVIvV5eT8Vc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GqRM+MpPvKT7wPEa86QzRv5nR4wOkCbRLGqVIEKHoSbN1OghQOa54p3lkavvSKeFU YWxZPxa+XWeH+WGoN7a+FhC9Hfa+We35ANCxJaa/tAJl4tZkpGDczkTWwzFb8ky1GL L/5rZVYMy/uTM1jRFU7Knnzklq3h+d2R6IRFO3tE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Raju Rangoju , Jason Gunthorpe , Sasha Levin Subject: [PATCH 4.19 117/187] iw_cxgb4: fix srqidx leak during connection abort Date: Thu, 4 Apr 2019 10:47:34 +0200 Message-Id: <20190404084608.768122439@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190404084603.119654039@linuxfoundation.org> References: <20190404084603.119654039@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ [ 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 0f83cbec33f3..a68569ec86bf 100644 --- a/drivers/infiniband/hw/cxgb4/cm.c +++ b/drivers/infiniband/hw/cxgb4/cm.c @@ -1904,8 +1904,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; } @@ -3608,7 +3610,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