From patchwork Tue Mar 8 15:49:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 8535441 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6FF27C0553 for ; Tue, 8 Mar 2016 15:48:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E30B02014A for ; Tue, 8 Mar 2016 15:48:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2645920131 for ; Tue, 8 Mar 2016 15:48:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932195AbcCHPr7 (ORCPT ); Tue, 8 Mar 2016 10:47:59 -0500 Received: from mail-wm0-f41.google.com ([74.125.82.41]:32837 "EHLO mail-wm0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750773AbcCHPrz (ORCPT ); Tue, 8 Mar 2016 10:47:55 -0500 Received: by mail-wm0-f41.google.com with SMTP id l68so155617114wml.0 for ; Tue, 08 Mar 2016 07:47:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=szeredi.hu; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=9pjAm8rc/aIMBmI+Jf/anfzW4kX0wJW8j0/sPRYs27w=; b=TaM/KXrvSPD0zM4m6fbnKtoF3VAXbzRYsKjXLIQKjcEr5QNQ2UJ0diWZ0KNwUIuXmd CLeE95TyVAuenSo8BR/0f5iGFIhzz9DN8vqDXfB2A7Q471UHKaYGVJt5clbZQ+fJnEd5 wqXCIqzyernVXaBNXj9tr0DP4QGVMBdKBNjTk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=9pjAm8rc/aIMBmI+Jf/anfzW4kX0wJW8j0/sPRYs27w=; b=OzFkqdiTe3uRV9jSvGE/zmFZnKCqUUx0cuLTdklnfNMAER2FYeACfFvdfZirWFjCSc /jSkc2QnDVwWZN7j0CciaPgDSbcueiP5Mvs+Im/DHmuH/PYy+2cw+boy/MJPKGV1eWda jYr9+muheYZinhoCPgL09rvFNzH5UKUbQAnu6m0yWFqQVH78UMVPBg7jUoNDhzBWvRnL QyUyJXHqz5aIEpMOTnVXKGBNDDlCpP3oL+JUBmXeNY1lLR1hK2jYby+782z5XQUU4JnM ulx86IIe88dVHEZ7XgqCc3i3mwUlauSv2PJqiLX/VYZpyhsicqGIni3Tk7jM/bactI/p x34w== X-Gm-Message-State: AD7BkJJG8cd2lnmQybVdo7o4CZf1wA7sdjHY7ohb2GeXTBwELifkfo+WWkr5syqCqAZwrQ== X-Received: by 10.194.6.36 with SMTP id x4mr14298321wjx.122.1457452074228; Tue, 08 Mar 2016 07:47:54 -0800 (PST) Received: from tucsk (pool-dsl-2c-0018.externet.hu. [217.173.44.24]) by smtp.gmail.com with ESMTPSA id hq2sm3577301wjb.3.2016.03.08.07.47.52 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 08 Mar 2016 07:47:53 -0800 (PST) Date: Tue, 8 Mar 2016 16:49:04 +0100 From: Miklos Szeredi To: linux-unionfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org Cc: Goldwyn Rodrigues , Trond Myklebust Subject: [PATCH 2/2] nfs: use file_dentry() Message-ID: <20160308154904.GD8655@tucsk> References: <20160308154716.GC8655@tucsk> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20160308154716.GC8655@tucsk> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@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 Cc: Trond Myklebust Tested-by: Goldwyn Rodrigues Acked-by: Trond Myklebust --- fs/nfs/dir.c | 6 +++--- fs/nfs/inode.c | 2 +- fs/nfs/nfs4file.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -377,7 +377,7 @@ int nfs_readdir_xdr_filler(struct page * 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_ 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_revalid */ 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; --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -940,7 +940,7 @@ int nfs_open(struct inode *inode, struct { 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); --- 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, stru 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;