Skip to content

Commit

Permalink
Btrfs: fix permissions of empty files not affected by umask
Browse files Browse the repository at this point in the history
When a new file is created with btrfs_create(), the inode will initially be
created with permissions 0666 and later on in btrfs_init_acl() it will be
adapted to mask out the umask bits. The problem is that this change won't make
it into the btrfs_inode unless there's another change to the inode (e.g. writing
content changing the size or touching the file changing the mtime.)

This fix adds a call to btrfs_update_inode() to btrfs_create() to make sure that
the change will not get lost if the in-memory inode is flushed before other
changes are made to the file.

Signed-off-by: Filipe Brandenburger <filbranden@google.com>
Reviewed-by: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
  • Loading branch information
Filipe Brandenburger authored and Chris Mason committed Dec 17, 2012
1 parent 31e5022 commit 9185aa5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fs/btrfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -5041,6 +5041,10 @@ static int btrfs_create(struct inode *dir, struct dentry *dentry,
if (err)
goto out_unlock;

err = btrfs_update_inode(trans, root, inode);
if (err)
goto out_unlock;

/*
* If the active LSM wants to access the inode during
* d_instantiate it needs these. Smack checks to see
Expand Down

0 comments on commit 9185aa5

Please sign in to comment.