Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5646240img; Wed, 27 Mar 2019 12:21:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqy7P6UikwKvKFgLmTTO4EBW9LbrlJ8JNlo7ogHVuqiavbTcRK6aXiMyR7VgI2PgLYv0wyPR X-Received: by 2002:a63:1912:: with SMTP id z18mr36914359pgl.115.1553714498839; Wed, 27 Mar 2019 12:21:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553714498; cv=none; d=google.com; s=arc-20160816; b=aUR2VtExrdyNlHqcvZetEbbyFFs0VMBLbKlA24FcN7UpYgneYUXbK0MMxs0ZVQ0yiS Q6UyO9KoRqLkWsddlMFl4vJ1Ad7hZqNcNy/cjdmSxRW4z8tMdIhDeAHEroumtsQgzEE4 2e+udGEgbLtI9KAUIWd+yBAzNyZ6OFUEDXttDiIy5VbhdDV/C32+c5Y7mSeLhSwajbko FOJGueo/ZPUjkqPjRBIOG3pW9Gb3TWWB1cRvS/Le6AYl2OvvgeVw56bBVv91tVfeya3x zBzfih/ySW9cpHpubRAXkpjp9nbicWNOAAqGtOGYJkYmRh2fjG0R34IdvsSAtiCKag7C NlIA== 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=XpWz5Ncl0JG1PLE27tWksH0Zo/hq56tLp4ah+Zt/ksQ=; b=Jfm5WFksWWXa+hbwwUpFRMmYl+R1ItaXbQZGV1EkeAJgVI0wOZD7yNxyki4EHFbawg +YihpME+5I1KcFog+bS3Ffo3B5DI34R4VsSc9bBU26v6f2pzOgFq94KaPjFsT4lfH4t6 WZIowfKaKTq2YtmwRxILsH9WnqFh4O9GJd9BjKn1tl1iCs5Pg+pvR5yRXbwvBeB6gFPp K42GAsgw/Q6Mhhl5ioWQuh1voMnteNbTb3zUlT5AkrWFom/PH4ws48mMsTlZIDuq+0ew j5eklQ4DMgrnBwjEaOp1wc4dhwiT/4YcDGBUFOyi+RN6+ZIEfp76hqp7tVsd3812lhY/ YyVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jZ79oAoO; 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 m12si3894603pgc.157.2019.03.27.12.21.23; Wed, 27 Mar 2019 12:21:38 -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=jZ79oAoO; 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 S2387597AbfC0SHR (ORCPT + 99 others); Wed, 27 Mar 2019 14:07:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:49066 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387559AbfC0SHP (ORCPT ); Wed, 27 Mar 2019 14:07:15 -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 40A142183E; Wed, 27 Mar 2019 18:07:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553710035; bh=4hiEfMAFfTbNiq/86JD20ExMFo/r8DprnTdNcw+FGU8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jZ79oAoOvkT6P3cM/evxQPxGUj0QJauP0FU9gVe03G5Yp7xnJS4b29R4bJ3K1udXJ OE0UdvfhAeffdZ/UJHt0qe3duqjWCbg30G676M4bai5XzbbmibvRXW6pT6Sn24D+5V WfvwtHacVnK6zASArqGZq5AjQaOGOzEZ3npFJ0Uc= 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 5.0 166/262] iw_cxgb4: fix srqidx leak during connection abort Date: Wed, 27 Mar 2019 14:00:21 -0400 Message-Id: <20190327180158.10245-166-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327180158.10245-1-sashal@kernel.org> References: <20190327180158.10245-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 8221813219e5..25a81fbb0d4d 100644 --- a/drivers/infiniband/hw/cxgb4/cm.c +++ b/drivers/infiniband/hw/cxgb4/cm.c @@ -1903,8 +1903,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; } @@ -3606,7 +3608,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