Received: by 10.213.65.68 with SMTP id h4csp425570imn; Tue, 13 Mar 2018 08:40:28 -0700 (PDT) X-Google-Smtp-Source: AG47ELuaqgVLILByZgKkVl7oOJvSfaQixtekuTyEgU8SOpDkgLoMAY7Uqnc2V/Ag6RlpGqrExE3A X-Received: by 2002:a17:902:8f8e:: with SMTP id z14-v6mr932321plo.271.1520955628078; Tue, 13 Mar 2018 08:40:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520955628; cv=none; d=google.com; s=arc-20160816; b=Q53piLC1jE4NmAalC9AiiGRzrNFVh0/KRznoaj2yIul4lSUvan4a6uXLz8kiXaxW61 6jDBJeaTn/fDAwkf9O+arzl4J7rFPNlnhTxEiiAyp9ccrkG6J0AA6AY2UwVmUTYGj8J8 wNQEuX5LvZa91X3FhFMgAOpPqVBdSQZG0wvtemmY5QlH6kbGft99tm7g0N0xq5DvE7N7 hkNeuCXru9bWdJv3D70a8MibCfUKiJrUdk4rsVTISQrQ5CHA4k7TJwMl03jvbHLBjleL NhNbSsG3qwpN6tUkA6ivDpBP79sLTX/eNfcCwLuKxEKIXcApX7dC6pEkl0x0Tmn8sK0j hP0Q== 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=Xk62voB0XWm0aqpecCVOAtWjW/Xvn9XDEgzhBGRjcMo=; b=d2YybTHewfNE0TaZjZ7E9ewkauR33ym3WBHMHJdplhW3zInFHCyIR75lWCSMsQlt/j aLaV0x5ZXX6swreFj9Do8k2GrZAkGOtjTLCQz66yiZmHV1AvvRnY9ExYSMMeBAGqVHTp 2YyzGwBgFwHHmwqQNXPNU8ZBHzULcVU14tywq1prBsv8tcP+wwM4K8zelQ+JRRiP/UDn RR4V8P9z8yv/dgImjuu0UjDwRAsvOvuf7KtU0k710JlDDNkDkifxxpBNOVpytvJAwPUJ csUiS+fN9rN5A3PTvLvIyXrNhdI1x2h4sVdTs+UHilkI6oTDJ5pB2CTuwnOR01SU51HX veMA== 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 r4si255483pgs.685.2018.03.13.08.40.12; Tue, 13 Mar 2018 08:40:28 -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 S934371AbeCMPhX (ORCPT + 99 others); Tue, 13 Mar 2018 11:37:23 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:33910 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934343AbeCMPhT (ORCPT ); Tue, 13 Mar 2018 11:37:19 -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 B0F971238; Tue, 13 Mar 2018 15:37:18 +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.14 044/140] pNFS: Prevent the layout header refcount going to zero in pnfs_roc() Date: Tue, 13 Mar 2018 16:24:07 +0100 Message-Id: <20180313152501.064209567@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180313152458.201155692@linuxfoundation.org> References: <20180313152458.201155692@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.14-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 (atomic_dec_and_lock(&lo->plh_refcount, &inode->i_lock)) { @@ -1223,10 +1226,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); @@ -1294,10 +1299,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; }