From: Filipe Brandenburger <filbranden@google.com>
To: Chris Mason <chris.mason@fusionio.com>, linux-btrfs@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
Filipe Brandenburger <filbranden@google.com>
Subject: [PATCH 0/2] Btrfs: fix mode umasking on empty files
Date: Thu, 29 Nov 2012 19:40:07 -0800 [thread overview]
Message-ID: <1354246809-32339-1-git-send-email-filbranden@google.com> (raw)
Hi,
This set of patches fix bug #50861:
"Btrfs sometimes ignore umask and create world writable files"
https://bugzilla.kernel.org/show_bug.cgi?id=50861
It turns out that btrfs_create() will create an inode with permissions 0666 and
these will be changed to match the umask inside btrfs_init_acl() (and only in
cases where the ACL doesn't mandate which permissions the file should have.) The
changes are made to the "struct inode" but it's not marked as dirty, so these
changes will only propagate to the "struct btrfs_inode" if other changes are
made to the inode (e.g. by writing content and changing the size or by using
"touch" and changing the mtime, both of which will mark the inode as dirty.)
I fixed this issue by adding a call to btrfs_update_inode() in btrfs_create().
I believe this might be an acceptable solution since the same is already done on
most other system calls such as "mkdir" or "symlink".
An alternative might be applying the umask earlier, before the call to
btrfs_new_inode(), that way the inode would be created with the right permission
bits from the beginning, but that might either involve checking the ACLs before
creating the inode (which might need a rework of btrfs_init_acl()) or umasking
the bits unconditionally, but I guess there's a reason to apply that logic...
The first patch fixes the issue, the second patch refactors the code to avoid
the repetition of setting the flag variable on every error handling block.
Cheers,
Filipe
Filipe Brandenburger (2):
Btrfs: fix permissions of empty files not affected by umask
Btrfs: refactor error handling to drop inode in btrfs_create()
fs/btrfs/inode.c | 27 +++++++++++++++------------
1 file changed, 15 insertions(+), 12 deletions(-)
--
1.7.11.7
next reply other threads:[~2012-11-30 3:40 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-30 3:40 Filipe Brandenburger [this message]
2012-11-30 3:40 ` [PATCH 1/2] Btrfs: fix permissions of empty files not affected by umask Filipe Brandenburger
2012-11-30 3:40 ` [PATCH 2/2] Btrfs: refactor error handling to drop inode in btrfs_create() Filipe Brandenburger
2012-11-30 6:17 ` [PATCH 1/2] Btrfs: fix permissions of empty files not affected by umask Liu Bo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1354246809-32339-1-git-send-email-filbranden@google.com \
--to=filbranden@google.com \
--cc=chris.mason@fusionio.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®