Received: by 10.213.65.68 with SMTP id h4csp448993imn; Tue, 13 Mar 2018 09:23:13 -0700 (PDT) X-Google-Smtp-Source: AG47ELte38hi34oJxbdNRck/R6xnobIjdhm2fBp2fUS59ySs2HygpE0okJO5Kfmtal5pQr3e+n6H X-Received: by 10.99.115.84 with SMTP id d20mr975890pgn.362.1520958193608; Tue, 13 Mar 2018 09:23:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520958193; cv=none; d=google.com; s=arc-20160816; b=dvOnvlVyUa5c76AljKi2Wb5Cg9NFcvgWDf8sald23fub0lPZqZzffxC4aMEQhyQf9m GSYoSGvjwObY8RYmrP7k0jQpoL9v/n8OqLW+PswLuPDHjF9vCUvOgGjMpJGtewQf2H7p d4Ue/6/KXSQhcLyDGQt4CvIz3GXZqhK25DvL8b3G3N+Ij6dnGfucAGzBM7MNFDqchmyg /TpBZxJpCnnW09HVuuaafD8uWtAg2kQr2eUKb1w4lD+t1ugRnUM3eg3/6gUws68z2KIZ DUgUXKQ7ZyN+hJh0D6zqwVqXl57zp/TgAj7DxwMBTS3FL/LJNQiIdBlEurCW1xk1+X3+ MvVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=YYoF8mEbo4AwMzBExDCRd7sn+PqUy/LU2lmC9JUeRso=; b=kMOn3YPqrJBe/gI8enNVFuHkU5wQP0vSIMZ2/kmAes8FgZXWywiDkkiycgFm+vPvZu DqdRMcezYhI2weVRe6a0gH8q/4jpNeMqdGcziiIV0SSorNLJsgjKltZx+sTVUy8JCSEx crktjjfZS2BRGMKhuJ9/IC6KILvR5jpACQ8jsgwggr7gGhjWV1FMwe6Mwz3khkZzqMWo fmvsuWkAgxmumhIgzqUYWrfBk5W19pexmOf+RZNY0knhxjqGS0osUZnITZ6+StMEUPCm F+hxr8PMkOZD3Io6/0HeFH4sVDPYPopbPE8HibXmPYcY5SeDA/C0JVEVKXdODfQNIRsv 6x8w== ARC-Authentication-Results: i=1; mx.google.com; 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 q4-v6si277855plr.365.2018.03.13.09.22.59; Tue, 13 Mar 2018 09:23:13 -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; 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 S933776AbeCMPe3 (ORCPT + 99 others); Tue, 13 Mar 2018 11:34:29 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:32812 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933751AbeCMPe0 (ORCPT ); Tue, 13 Mar 2018 11:34:26 -0400 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 22B5E1032; Tue, 13 Mar 2018 15:34:25 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tigran Mkrtchyan , Trond Myklebust Subject: [PATCH 4.15 145/146] pNFS: Prevent the layout header refcount going to zero in pnfs_roc() Date: Tue, 13 Mar 2018 16:25:12 +0100 Message-Id: <20180313152331.265397479@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180313152320.439085687@linuxfoundation.org> References: <20180313152320.439085687@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Trond Myklebust commit 9c6376ebddad585da4238532dd6d90ae23ffee67 upstream. Ensure that we hold a reference to the layout header when processing the pNFS return-on-close so that the refcount value does not inadvertently go to zero. Reported-by: Tigran Mkrtchyan Signed-off-by: Trond Myklebust Cc: stable@vger.kernel.org # v4.10+ Tested-by: Tigran Mkrtchyan Signed-off-by: Greg Kroah-Hartman --- fs/nfs/pnfs.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -292,8 +292,11 @@ pnfs_detach_layout_hdr(struct pnfs_layou void pnfs_put_layout_hdr(struct pnfs_layout_hdr *lo) { - struct inode *inode = lo->plh_inode; + struct inode *inode; + if (!lo) + return; + inode = lo->plh_inode; pnfs_layoutreturn_before_put_layout_hdr(lo); if (refcount_dec_and_lock(&lo->plh_refcount, &inode->i_lock)) { @@ -1241,10 +1244,12 @@ retry: spin_lock(&ino->i_lock); lo = nfsi->layout; if (!lo || !pnfs_layout_is_valid(lo) || - test_bit(NFS_LAYOUT_BULK_RECALL, &lo->plh_flags)) + test_bit(NFS_LAYOUT_BULK_RECALL, &lo->plh_flags)) { + lo = NULL; goto out_noroc; + } + pnfs_get_layout_hdr(lo); if (test_bit(NFS_LAYOUT_RETURN_LOCK, &lo->plh_flags)) { - pnfs_get_layout_hdr(lo); spin_unlock(&ino->i_lock); wait_on_bit(&lo->plh_flags, NFS_LAYOUT_RETURN, TASK_UNINTERRUPTIBLE); @@ -1312,10 +1317,12 @@ out_noroc: struct pnfs_layoutdriver_type *ld = NFS_SERVER(ino)->pnfs_curr_ld; if (ld->prepare_layoutreturn) ld->prepare_layoutreturn(args); + pnfs_put_layout_hdr(lo); return true; } if (layoutreturn) pnfs_send_layoutreturn(lo, &stateid, iomode, true); + pnfs_put_layout_hdr(lo); return false; }