From: "Ernesto A. Fernández" <ernesto.mnd.fernandez@gmail.com>
To: Jan Kara <jack@suse.com>, Theodore Ts'o <tytso@mit.edu>,
Andreas Dilger <adilger.kernel@dilger.ca>,
Dave Kleikamp <shaggy@kernel.org>,
linux-ext4@vger.kernel.org, jfs-discussion@lists.sourceforge.net,
reiserfs-devel@vger.kernel.org
Subject: [PATCH 1/5] ext4: preserve i_mode if __ext4_set_acl() fails
Date: Wed, 12 Jul 2017 06:53:51 -0300 [thread overview]
Message-ID: <52152ec4b83fe0c406475bfee39efafaaa2a88fb.1499805486.git.ernesto.mnd.fernandez@gmail.com> (raw)
In-Reply-To: <cover.1499805484.git.ernesto.mnd.fernandez@gmail.com>
When changing a file's acl mask, __ext4_set_acl() will first set the group
bits of i_mode to the value of the mask, and only then set the actual
extended attribute representing the new acl.
If the second part fails (due to lack of space, for example) and the file
had no acl attribute to begin with, the system will from now on assume
that the mask permission bits are actual group permission bits, potentially
granting access to the wrong users.
Prevent this by only changing the inode mode after the acl has been set.
Signed-off-by: Ernesto A. Fernández <ernesto.mnd.fernandez@gmail.com>
---
fs/ext4/acl.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/fs/ext4/acl.c b/fs/ext4/acl.c
index 09441ae..2985cd0 100644
--- a/fs/ext4/acl.c
+++ b/fs/ext4/acl.c
@@ -189,16 +189,17 @@ __ext4_set_acl(handle_t *handle, struct inode *inode, int type,
void *value = NULL;
size_t size = 0;
int error;
+ int update_mode = 0;
+ umode_t mode = inode->i_mode;
switch (type) {
case ACL_TYPE_ACCESS:
name_index = EXT4_XATTR_INDEX_POSIX_ACL_ACCESS;
if (acl) {
- error = posix_acl_update_mode(inode, &inode->i_mode, &acl);
+ error = posix_acl_update_mode(inode, &mode, &acl);
if (error)
return error;
- inode->i_ctime = current_time(inode);
- ext4_mark_inode_dirty(handle, inode);
+ update_mode = 1;
}
break;
@@ -221,8 +222,14 @@ __ext4_set_acl(handle_t *handle, struct inode *inode, int type,
value, size, xattr_flags);
kfree(value);
- if (!error)
+ if (!error) {
set_cached_acl(inode, type, acl);
+ if (update_mode) {
+ inode->i_mode = mode;
+ inode->i_ctime = current_time(inode);
+ ext4_mark_inode_dirty(handle, inode);
+ }
+ }
return error;
}
--
2.1.4
next prev parent reply other threads:[~2017-07-12 9:53 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-12 9:53 [PATCH 0/5] Failure to set acl may alter group permissions Ernesto A. Fernández
2017-07-12 9:53 ` Ernesto A. Fernández [this message]
2017-07-17 15:33 ` [PATCH 1/5] ext4: preserve i_mode if __ext4_set_acl() fails Jan Kara
2017-07-31 2:44 ` Theodore Ts'o
2017-07-12 9:54 ` [PATCH 2/5] ext2: preserve i_mode if ext2_set_acl() fails Ernesto A. Fernández
2017-07-17 16:33 ` Jan Kara
2017-07-12 9:54 ` [PATCH 3/5] ext2: fix line over 80 characters in ext2_set_acl() Ernesto A. Fernández
2017-07-17 16:33 ` Jan Kara
2017-07-12 9:55 ` [PATCH 4/5] jfs: preserve i_mode if __jfs_set_acl() fails Ernesto A. Fernández
2017-07-13 21:01 ` Dave Kleikamp
2017-07-12 9:56 ` [PATCH 5/5] reiserfs: preserve i_mode if __reiserfs_set_acl() fails Ernesto A. Fernández
2017-07-17 16:45 ` Jan Kara
2017-07-12 11:47 ` [PATCH 0/5] Failure to set acl may alter group permissions Christoph Hellwig
2017-07-13 9:40 ` [xfstests PATCH] generic: add test of file mode when setfacl fails Ernesto A. Fernández
2017-07-13 11:55 ` Christoph Hellwig
2017-07-14 5:40 ` Ernesto A. Fernández
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=52152ec4b83fe0c406475bfee39efafaaa2a88fb.1499805486.git.ernesto.mnd.fernandez@gmail.com \
--to=ernesto.mnd.fernandez@gmail.com \
--cc=adilger.kernel@dilger.ca \
--cc=jack@suse.com \
--cc=jfs-discussion@lists.sourceforge.net \
--cc=linux-ext4@vger.kernel.org \
--cc=reiserfs-devel@vger.kernel.org \
--cc=shaggy@kernel.org \
--cc=tytso@mit.edu \
/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;
as well as URLs for NNTP newsgroup(s).