Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1023294ybe; Wed, 4 Sep 2019 11:17:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqwxKDGIYSFW3o8BGaIVq7CelLOuUpOHbEuFZv7/YG1YWw5eEmg//f8x5AgTcgD7tHffWL2o X-Received: by 2002:a17:90a:fa89:: with SMTP id cu9mr6204623pjb.139.1567621058446; Wed, 04 Sep 2019 11:17:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567621058; cv=none; d=google.com; s=arc-20160816; b=LToqWWEtK2nirXCp+NFVtTI84Eni6C8uujnzwcI+2cdyfKEICMzYmXWFVjQZVx602Z XRBGb15nV5YFT1obLZJ/5n4w4Rrpbs1UsVQc4cWx6REDU83YA/bOVKfDd43KkPrm2fJo V2f4B7/T3jaRllrOJyZDeNOx+dPN9OwsURadIaEz3aWEHl3grxYC3LspS99DleLhl5Vf 19qbvDXKdu9T209r14lQBZc0ui5l6yGArYmTUr5WYWqLKe34a9hBT/04eKgbTc5WiOgv 1FHTDokenxabpAhFTNW17RoySLaJwD0HyNS99B7wY5yWddxTCNnKGWyjqqnAh2REblRP PZ7A== 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=d6beeVt5DSmo9ThJxwOWXUUZZD8RWZkFOkEAT/gIs78=; b=RK3NUnaIzw2erOJyaxFg+oW5id5ViqIoY2VIyq2QMlsdK0DhGb1FNd+Fs7rHpmmfKr iYrvDJuBBoKWeUxvCTNZ/RHIiIzrZerhskLKQRgeS1DN3RZKajyqZ6tamSChSTGlG9WO Ym0g8WlLVrawaXbC6aLAe+hC4Z2uyKCeR7WBM5OvWFrXaugI3n2PFp7mijO/wDGmCuiw SANSIPgDSAj3vEk3jqjXVnIizEJfXmCTUBCLK+JtILfOJXC8bYpQVYf3mbCtcnZ4hUYx h+nyjHqyRYx58VKtNO51HQe/b9eTjyzidValoI5VObNNqf4LeBUFgjF/upgHMG7e3hIy 9yiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=URawB6nV; 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 r9si18374826pli.405.2019.09.04.11.17.23; Wed, 04 Sep 2019 11:17: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=URawB6nV; 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 S2390953AbfIDSPV (ORCPT + 99 others); Wed, 4 Sep 2019 14:15:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:60858 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390949AbfIDSPT (ORCPT ); Wed, 4 Sep 2019 14:15:19 -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 003BE23400; Wed, 4 Sep 2019 18:15:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567620918; bh=wzdzttJzLdxJMiPAyhMuDzxSVX/sJd8goyf39tXfyfY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=URawB6nVftJvV0tH/cEPmId8ePTdlgZi3aetUqOFk4Q76S10QIU0diTUJta/F56LA ykPCy6uoLF9fEaEFiFm5m2GVPmqC6XjFKsuUYFVI0G1M7sqTFNBThJCmvg2xTMWrCb zgKPrxfK3Z0Jv9fkOBq33s876BlLszFgZjhITTT8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Trond Myklebust Subject: [PATCH 5.2 104/143] NFSv4/pnfs: Fix a page lock leak in nfs_pageio_resend() Date: Wed, 4 Sep 2019 19:54:07 +0200 Message-Id: <20190904175318.378060883@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190904175314.206239922@linuxfoundation.org> References: <20190904175314.206239922@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 From: Trond Myklebust commit f4340e9314dbfadc48758945f85fc3b16612d06f upstream. 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: Greg Kroah-Hartman --- fs/nfs/pagelist.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) --- a/fs/nfs/pagelist.c +++ b/fs/nfs/pagelist.c @@ -1253,20 +1253,22 @@ static void nfs_pageio_complete_mirror(s 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; }