From patchwork Thu Mar 17 09:02:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 8608381 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 85BA19F6E1 for ; Thu, 17 Mar 2016 09:02:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8B6332026F for ; Thu, 17 Mar 2016 09:02:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 149042022A for ; Thu, 17 Mar 2016 09:02:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933333AbcCQJBZ (ORCPT ); Thu, 17 Mar 2016 05:01:25 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:35269 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932689AbcCQJA5 (ORCPT ); Thu, 17 Mar 2016 05:00:57 -0400 Received: by mail-wm0-f65.google.com with SMTP id l124so7700249wmf.2 for ; Thu, 17 Mar 2016 02:00:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=szeredi.hu; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=kS4QxJHrr9Gvm33bH9bG736YP5HLKIA1iXe7+i55TCM=; b=J8nHyng4qHSG9wLoQjD1iajUfpQAjrk7RZh//A+zkiPDSPLW9a1cJkYOcbVwTZwR1+ wJvsLgueB0cCqdzno4Sl0bWO0jlmXEzU0rcxYw3CnOb7SkjkbacNEjjcCS4rTJFWQbVn /CE3lgZvRZ7yv9IiqozRXoU7xJRpftVrEfOiQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=kS4QxJHrr9Gvm33bH9bG736YP5HLKIA1iXe7+i55TCM=; b=hKEBsJqnFvRuPkIgDkAOP/2xdi0MjJQcK/xTM+vTPASqa0/+kix8OiAuUAjfk0VRM3 xicEd4mjSrnQOMyB5ghKic3CcMEK1WJnrchn4Pq+yIyMOi09Nlx6VqM1n+CtKYVXDCjl Wwnh1XYafKgLwawC6esTbaVsNl08UA3K6LPmvCOTNCerGml5vaZvCaQwczWuweUDcA+T lV05DU1LBJMZLIVvmITAacwfGaSu64MGvOxzn3rku9EeAFhjFx0a7oqAO4oKe9FBpLkG y1SzYOiSAutwAx+DhEO5WkpWtXT4EnePQuq33MRAaRK5gV/QyMrg+vfXRqd83BXGTbeu bhXw== X-Gm-Message-State: AD7BkJJdsadBIB7cp4NnXfz+euWtbqcgQWbakftQQ3fBJ76QIzPW+SUPgfzQvmjPDzEtvQ== X-Received: by 10.28.53.4 with SMTP id c4mr9518277wma.34.1458205255908; Thu, 17 Mar 2016 02:00:55 -0700 (PDT) Received: from tucsk.pomaz.szeredi.hu (pool-dsl-2c-0018.externet.hu. [217.173.44.24]) by smtp.gmail.com with ESMTPSA id n66sm7110841wmg.20.2016.03.17.02.00.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 17 Mar 2016 02:00:55 -0700 (PDT) From: Miklos Szeredi To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: dhowells@redhat.com, viro@zeniv.linux.org.uk, Goldwyn Rodrigues , Trond Myklebust , Subject: [PATCH 2/4] nfs: use file_dentry() Date: Thu, 17 Mar 2016 10:02:01 +0100 Message-Id: <1458205323-25685-2-git-send-email-miklos@szeredi.hu> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1458205323-25685-1-git-send-email-miklos@szeredi.hu> References: <1458205323-25685-1-git-send-email-miklos@szeredi.hu> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Miklos Szeredi NFS may be used as lower layer of overlayfs and accessing f_path.dentry can lead to a crash. Fix by replacing direct access of file->f_path.dentry with the file_dentry() accessor, which will always return a native object. Fixes: 4bacc9c9234c ("overlayfs: Make f_path always point to the overlay and f_inode to the underlay") Signed-off-by: Miklos Szeredi Tested-by: Goldwyn Rodrigues Acked-by: Trond Myklebust Cc: # v4.2 Cc: David Howells Cc: Al Viro --- fs/nfs/dir.c | 6 +++--- fs/nfs/inode.c | 2 +- fs/nfs/nfs4file.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 9cce67043f92..7ded17764754 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -377,7 +377,7 @@ int nfs_readdir_xdr_filler(struct page **pages, nfs_readdir_descriptor_t *desc, again: timestamp = jiffies; gencount = nfs_inc_attr_generation_counter(); - error = NFS_PROTO(inode)->readdir(file->f_path.dentry, cred, entry->cookie, pages, + error = NFS_PROTO(inode)->readdir(file_dentry(file), cred, entry->cookie, pages, NFS_SERVER(inode)->dtsize, desc->plus); if (error < 0) { /* We requested READDIRPLUS, but the server doesn't grok it */ @@ -560,7 +560,7 @@ int nfs_readdir_page_filler(nfs_readdir_descriptor_t *desc, struct nfs_entry *en count++; if (desc->plus != 0) - nfs_prime_dcache(desc->file->f_path.dentry, entry); + nfs_prime_dcache(file_dentry(desc->file), entry); status = nfs_readdir_add_to_array(entry, page); if (status != 0) @@ -864,7 +864,7 @@ static bool nfs_dir_mapping_need_revalidate(struct inode *dir) */ static int nfs_readdir(struct file *file, struct dir_context *ctx) { - struct dentry *dentry = file->f_path.dentry; + struct dentry *dentry = file_dentry(file); struct inode *inode = d_inode(dentry); nfs_readdir_descriptor_t my_desc, *desc = &my_desc; diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 86faecf8f328..847b678af4f0 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -940,7 +940,7 @@ int nfs_open(struct inode *inode, struct file *filp) { struct nfs_open_context *ctx; - ctx = alloc_nfs_open_context(filp->f_path.dentry, filp->f_mode); + ctx = alloc_nfs_open_context(file_dentry(filp), filp->f_mode); if (IS_ERR(ctx)) return PTR_ERR(ctx); nfs_file_set_open_context(filp, ctx); diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c index 57ca1c8039c1..2a9ff14cfb3b 100644 --- a/fs/nfs/nfs4file.c +++ b/fs/nfs/nfs4file.c @@ -26,7 +26,7 @@ static int nfs4_file_open(struct inode *inode, struct file *filp) { struct nfs_open_context *ctx; - struct dentry *dentry = filp->f_path.dentry; + struct dentry *dentry = file_dentry(filp); struct dentry *parent = NULL; struct inode *dir; unsigned openflags = filp->f_flags; @@ -57,7 +57,7 @@ nfs4_file_open(struct inode *inode, struct file *filp) parent = dget_parent(dentry); dir = d_inode(parent); - ctx = alloc_nfs_open_context(filp->f_path.dentry, filp->f_mode); + ctx = alloc_nfs_open_context(file_dentry(filp), filp->f_mode); err = PTR_ERR(ctx); if (IS_ERR(ctx)) goto out;