From patchwork Mon Aug 24 08:29:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 264951 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4BFB9C433E3 for ; Mon, 24 Aug 2020 09:56:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2278A2071E for ; Mon, 24 Aug 2020 09:56:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598263001; bh=TDK2CWXv9VIzmd0uFJf8Vwj/ZVwsjQ9xuND2ihko3c4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=OVIEaVYIivMT3SZjRQR3Ar7ucxzAs0mWdLrqyt3XIf9fch6XAS6p98HzLf77wCjIC g38irG1/FTDQdwTlirG6GRo9NfIXKP8i6v6iZt3al66+yrxXfasksGAb1pZrQ2WpQc /C1LwZfOI5BLsvhvpHvu9wqi76LSALM5YAc+goz8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726834AbgHXIfe (ORCPT ); Mon, 24 Aug 2020 04:35:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:46238 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726670AbgHXIfa (ORCPT ); Mon, 24 Aug 2020 04:35:30 -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 16826204FD; Mon, 24 Aug 2020 08:35:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598258129; bh=TDK2CWXv9VIzmd0uFJf8Vwj/ZVwsjQ9xuND2ihko3c4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZA5D3tIULahvUIEEcBFrTSUe9pWooJdwr6IDfo9ZPa9S+ncZCq3sQFa67jYu2b0q6 x70kShYs7nJZKo+l7Ky78UCO8kcVQcwVQGfdI8YwAZ7tFQgPhOJFAHdlidn02TflUS oFjmZZs7UGImnKypZO1oWNP3uJJNl9GqwWnSddoU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chuck Lever , Sasha Levin Subject: [PATCH 5.8 056/148] svcrdma: Fix another Receive buffer leak Date: Mon, 24 Aug 2020 10:29:14 +0200 Message-Id: <20200824082416.752092929@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200824082413.900489417@linuxfoundation.org> References: <20200824082413.900489417@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Chuck Lever [ Upstream commit 64d26422516b2e347b32e6d9b1d40b3c19a62aae ] During a connection tear down, the Receive queue is flushed before the device resources are freed. Typically, all the Receives flush with IB_WR_FLUSH_ERR. However, any pending successful Receives flush with IB_WR_SUCCESS, and the server automatically posts a fresh Receive to replace the completing one. This happens even after the connection has closed and the RQ is drained. Receives that are posted after the RQ is drained appear never to complete, causing a Receive resource leak. The leaked Receive buffer is left DMA-mapped. To prevent these late-posted recv_ctxt's from leaking, block new Receive posting after XPT_CLOSE is set. Signed-off-by: Chuck Lever Signed-off-by: Sasha Levin --- net/sunrpc/xprtrdma/svc_rdma_recvfrom.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c index e426fedb9524f..ac16d83f2d26c 100644 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c @@ -265,6 +265,8 @@ static int svc_rdma_post_recv(struct svcxprt_rdma *rdma) { struct svc_rdma_recv_ctxt *ctxt; + if (test_bit(XPT_CLOSE, &rdma->sc_xprt.xpt_flags)) + return 0; ctxt = svc_rdma_recv_ctxt_get(rdma); if (!ctxt) return -ENOMEM;