Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1010783ybe; Wed, 4 Sep 2019 11:06:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqyex9ogLZ2TawKYUuKQgtRqDX8iktpLCKHR/uph9lkuJl3DDhbP1coz/pX2Na3eExLy4hQD X-Received: by 2002:a65:64cf:: with SMTP id t15mr35395628pgv.88.1567620395644; Wed, 04 Sep 2019 11:06:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567620395; cv=none; d=google.com; s=arc-20160816; b=VPWYKomf5vubYujYpKCV7RJZ/8utjsDyn0/gtw11knZwe4+H2ZgHT36sG27nHt6V3q C//pAmVYk+PFifylJCQG3ejoSW+6IbQr4H0UDbgz7xVjRqCcASwhJFAymJAn9jV3dSpP 0yfoSDKhcLEnmvR0lnTcw7gZ+pxpNT5/jZYhnZnOdyxM1pSuNKzdRxMp29geCsqOeVLv jlgVIPdA2I3ETOCOaaRbZ1fTGSpnD/3jvTkflfQ/mJEZ+vGSwMPYp/2zWSk5Dqbnrgmd gE2bsNKlOfqZTqJSMss2YfafYfT+5Vdfb9mIQnfVJWKRFAJmiDEmq5mPM0fCkjku+nYk tlPw== 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=a8dnfRpM9lPhtvwjsEi+w5fgb6mGAxrRgKzNGkc7xfU=; b=do8u4lVZdUJKPNcF5a37wB6d0jWqlnL4m1KoS85nYnrDO4KhuDQg1SyTB69KYmo8Hn /Vevqz11jM49VkC4jzp2oEkS/QUotZB+jjk3D9WCABHz4Ren65sUcdlluH0XlLk89pQ8 kLrWBTIMpkWTrzDE+autH2avsxoOvtVJJDqg7ZPAh7I5tLQ5Fix4x5iNVq6xi0/yze3U EMtPR9Pg0zO8TVjkskWBtO7IccZF4kmxred63ucSD4ab/t3WyyQ8MzovSlclul4Q2ORs dCTKIf0nlaTGtI9sZBb8STzjaNRlqIfqyLaVdlnugonu8Dr7fF34veiNOyPdn5nWYdVt IojQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MCJrQehF; 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 h125si21498755pfb.119.2019.09.04.11.06.14; Wed, 04 Sep 2019 11:06:35 -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=MCJrQehF; 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 S2387466AbfIDSEd (ORCPT + 99 others); Wed, 4 Sep 2019 14:04:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:45548 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389082AbfIDSE2 (ORCPT ); Wed, 4 Sep 2019 14:04:28 -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 847F822CEA; Wed, 4 Sep 2019 18:04:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567620268; bh=azGO1qmg/UaSPqmktxHgfqCnVRUIkWMbvB4vhJz8qWw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MCJrQehFKgElasCJ96d1B4H+/WIq6ljdbQGr2vV5dy9A3D7/20AR3PTu7yFw8ZV4V oNl8ddM48A18bXn9GfWV9fljEi2stCzSp/NNxzFVCE60HAajSye0NsODNfI46fWLo7 5ngZnD1+gczgieLysWJWNY4Wum0euL6+hF9Y8LAM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Trond Myklebust , Sasha Levin Subject: [PATCH 4.14 53/57] NFSv4/pnfs: Fix a page lock leak in nfs_pageio_resend() Date: Wed, 4 Sep 2019 19:54:21 +0200 Message-Id: <20190904175307.112494039@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190904175301.777414715@linuxfoundation.org> References: <20190904175301.777414715@linuxfoundation.org> User-Agent: quilt/0.66 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 [ Upstream commit f4340e9314dbfadc48758945f85fc3b16612d06f ] If the attempt to resend the pages fails, we need to ensure that we clean up those pages that were not transmitted. Fixes: d600ad1f2bdb ("NFS41: pop some layoutget errors to application") Signed-off-by: Trond Myklebust Cc: stable@vger.kernel.org # v4.5+ Signed-off-by: Sasha Levin --- fs/nfs/pagelist.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c index a7aa028a5b0bb..ae598e45b2df0 100644 --- a/fs/nfs/pagelist.c +++ b/fs/nfs/pagelist.c @@ -1231,20 +1231,22 @@ static void nfs_pageio_complete_mirror(struct nfs_pageio_descriptor *desc, int nfs_pageio_resend(struct nfs_pageio_descriptor *desc, struct nfs_pgio_header *hdr) { - LIST_HEAD(failed); + LIST_HEAD(pages); desc->pg_io_completion = hdr->io_completion; desc->pg_dreq = hdr->dreq; - while (!list_empty(&hdr->pages)) { - struct nfs_page *req = nfs_list_entry(hdr->pages.next); + list_splice_init(&hdr->pages, &pages); + while (!list_empty(&pages)) { + struct nfs_page *req = nfs_list_entry(pages.next); if (!nfs_pageio_add_request(desc, req)) - nfs_list_move_request(req, &failed); + break; } nfs_pageio_complete(desc); - if (!list_empty(&failed)) { - list_move(&failed, &hdr->pages); - return desc->pg_error < 0 ? desc->pg_error : -EIO; + if (!list_empty(&pages)) { + int err = desc->pg_error < 0 ? desc->pg_error : -EIO; + hdr->completion_ops->error_cleanup(&pages, err); + return err; } return 0; } -- 2.20.1