diff mbox

NFS: Fix potential race in nfs_fhget()

Message ID 1466021128-62407-1-git-send-email-trond.myklebust@primarydata.com (mailing list archive)
State New, archived
Headers show

Commit Message

Trond Myklebust June 15, 2016, 8:05 p.m. UTC
If we don't set the mode correctly in nfs_init_locked(), then there is
potential for a race with a second call to nfs_fhget that will cause
inode aliasing.

Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
---
 fs/nfs/inode.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Jeff Layton June 16, 2016, 2:04 p.m. UTC | #1
On Wed, 2016-06-15 at 16:05 -0400, Trond Myklebust wrote:
> If we don't set the mode correctly in nfs_init_locked(), then there
> is
> potential for a race with a second call to nfs_fhget that will cause
> inode aliasing.
> 
> Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
> ---
>  fs/nfs/inode.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
> index 52e7d6869e3b..dda689d7a8a7 100644
> --- a/fs/nfs/inode.c
> +++ b/fs/nfs/inode.c
> @@ -282,6 +282,7 @@ nfs_init_locked(struct inode *inode, void
> *opaque)
>  	struct nfs_fattr	*fattr = desc->fattr;
>  
>  	set_nfs_fileid(inode, fattr->fileid);
> +	inode->i_mode = fattr->mode;
>  	nfs_copy_fh(NFS_FH(inode), desc->fh);
>  	return 0;
>  }

Good catch!

Reviewed-by: Jeff Layton <jlayton@redhat.com>
--
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
diff mbox

Patch

diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 52e7d6869e3b..dda689d7a8a7 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -282,6 +282,7 @@  nfs_init_locked(struct inode *inode, void *opaque)
 	struct nfs_fattr	*fattr = desc->fattr;
 
 	set_nfs_fileid(inode, fattr->fileid);
+	inode->i_mode = fattr->mode;
 	nfs_copy_fh(NFS_FH(inode), desc->fh);
 	return 0;
 }