From patchwork Tue Sep 20 16:55:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 9342107 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9E069607D0 for ; Tue, 20 Sep 2016 16:56:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8FB8F29495 for ; Tue, 20 Sep 2016 16:56:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 848F02996E; Tue, 20 Sep 2016 16:56:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2EE6629495 for ; Tue, 20 Sep 2016 16:56:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754132AbcITQ4T (ORCPT ); Tue, 20 Sep 2016 12:56:19 -0400 Received: from mail-qt0-f194.google.com ([209.85.216.194]:34983 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753999AbcITQ4S (ORCPT ); Tue, 20 Sep 2016 12:56:18 -0400 Received: by mail-qt0-f194.google.com with SMTP id 38so722891qte.2 for ; Tue, 20 Sep 2016 09:56:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=53bo39joZp7nLrWnf9KGgswBYVk/JWHw6vSg6CJc798=; b=iT4Xgxe28RdI9sMvAzEP3w+vg3xVfvGRwygteGi0JVcUIwP2uI7PnZa+N9tFy9PvoO H/t7G42Cmw29dKVcIl+3t9sB9w9MDQa5Zef9RoeFWX8WQljjJi1Ai+XVfjjxPSOHEtRN i7n9CFmS7jXSfeihOgxylrKGcigKxF/Nw6tJCG2JKz0thx23inVNhiPGKH6Qhdq+Rjlb bQGrDEtXlVHyL1W4zj8nped64md+cHxzP/9K6MBaoDXdD3CSO28LGpShzCnQicvTG6QW Q3vgeOSRbDHePVQAGa3nCObEtQ6zc96LDdHyDOsBm0us4UsiDDOTfMvHil5jMBH6kPQa JChQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=53bo39joZp7nLrWnf9KGgswBYVk/JWHw6vSg6CJc798=; b=agjo6GLqbxtLY5IqQ7BETu9jH3V5S3rArycyS5aU7r8V9i0GGP+xie68/xddL2M4L2 E8+kDtJl6xNpfRIyEKlSzPl215mg+HJlk8hIGchwCFwRXmqtd6MsdtIx0BhGd58Thhem HjV8tsc00AIpnzIHByol4TriaO52V7sYPj6nZ+rPcEWZqrnzhRHo6eGJA4xzjumWgtsy h/94A7NK06UgIuzDf3I6UeWkAFTJRxBoG0ug/pbHLOp7+pyaHZgFzfaqUYxj6MHsw8Uk 4T6RmlxGrpiF5iV8HltMbtavfbZAMFrNkH+oYb1uDCc2ml6oDB1edfcj97tT2M3rYS0H Vidg== X-Gm-Message-State: AE9vXwMiTStcwNdV8ZIe5WtKy27NMNDtoaB8tIrA4Yba4CB0ZBrqKEKGxpw/CeyCCl6IuA== X-Received: by 10.200.41.243 with SMTP id 48mr35976710qtt.20.1474390577553; Tue, 20 Sep 2016 09:56:17 -0700 (PDT) Received: from leira.trondhjem.org.localdomain (50-108-86-94.adr01.mskg.mi.frontiernet.net. [50.108.86.94]) by smtp.gmail.com with ESMTPSA id i4sm16537202qte.40.2016.09.20.09.56.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Sep 2016 09:56:17 -0700 (PDT) From: Trond Myklebust To: anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org, Oleg Drokin Subject: [PATCH v6 02/29] NFS: Fix inode corruption in nfs_prime_dcache() Date: Tue, 20 Sep 2016 12:55:44 -0400 Message-Id: <1474390571-17106-3-git-send-email-trond.myklebust@primarydata.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1474390571-17106-2-git-send-email-trond.myklebust@primarydata.com> References: <1474390571-17106-1-git-send-email-trond.myklebust@primarydata.com> <1474390571-17106-2-git-send-email-trond.myklebust@primarydata.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Due to inode number reuse in filesystems, we can end up corrupting the inode on our client if we apply the file attributes without ensuring that the filehandle matches. Typical symptoms include spurious "mode changed" reports in the syslog. We still do want to ensure that we don't invalidate the dentry if the inode number matches, but we don't have a filehandle. Fixes: fa9233699cc1 ("NFS: Don't require a filehandle to refresh...") Signed-off-by: Trond Myklebust Cc: stable@vger.kernel.org # v4.0+ --- fs/nfs/dir.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 177fefb26c18..578c8ce1aca1 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -435,11 +435,11 @@ int nfs_same_file(struct dentry *dentry, struct nfs_entry *entry) return 0; nfsi = NFS_I(inode); - if (entry->fattr->fileid == nfsi->fileid) - return 1; - if (nfs_compare_fh(entry->fh, &nfsi->fh) == 0) - return 1; - return 0; + if (entry->fattr->fileid != nfsi->fileid) + return 0; + if (entry->fh->size && nfs_compare_fh(entry->fh, &nfsi->fh) != 0) + return 0; + return 1; } static @@ -517,6 +517,8 @@ again: &entry->fattr->fsid)) goto out; if (nfs_same_file(dentry, entry)) { + if (!entry->fh->size) + goto out; nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); status = nfs_refresh_inode(d_inode(dentry), entry->fattr); if (!status) @@ -529,6 +531,8 @@ again: goto again; } } + if (!entry->fh->size) + goto out; inode = nfs_fhget(dentry->d_sb, entry->fh, entry->fattr, entry->label); alias = d_splice_alias(inode, dentry);