From: Dave Kleikamp <dave.kleikamp@oracle.com>
To: "Ernesto A. Fernández" <ernesto.mnd.fernandez@gmail.com>,
"Jan Kara" <jack@suse.com>, "Theodore Ts'o" <tytso@mit.edu>,
"Andreas Dilger" <adilger.kernel@dilger.ca>,
linux-ext4@vger.kernel.org, jfs-discussion@lists.sourceforge.net,
reiserfs-devel@vger.kernel.org
Subject: Re: [PATCH 4/5] jfs: preserve i_mode if __jfs_set_acl() fails
Date: Thu, 13 Jul 2017 16:01:42 -0500 [thread overview]
Message-ID: <9edc918e-619d-7b07-696d-c0184e42c58d@oracle.com> (raw)
In-Reply-To: <fb576cd6fe08fb4dc61970442c529f1a3ab02b71.1499805488.git.ernesto.mnd.fernandez@gmail.com>
On 07/12/2017 04:55 AM, Ernesto A. Fernández wrote:
> When changing a file's acl mask, __jfs_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.
This looks good to me. I'll add it to the jfs queue.
Thanks,
Shaggy
>
> Signed-off-by: Ernesto A. Fernández <ernesto.mnd.fernandez@gmail.com>
> ---
> fs/jfs/acl.c | 15 +++++++++++----
> 1 file changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/fs/jfs/acl.c b/fs/jfs/acl.c
> index 7bc186f..db5a385 100644
> --- a/fs/jfs/acl.c
> +++ b/fs/jfs/acl.c
> @@ -73,16 +73,17 @@ static int __jfs_set_acl(tid_t tid, struct inode *inode, int type,
> int rc;
> int size = 0;
> char *value = NULL;
> + int update_mode = 0;
> + umode_t mode = inode->i_mode;
>
> switch (type) {
> case ACL_TYPE_ACCESS:
> ea_name = XATTR_NAME_POSIX_ACL_ACCESS;
> if (acl) {
> - rc = posix_acl_update_mode(inode, &inode->i_mode, &acl);
> + rc = posix_acl_update_mode(inode, &mode, &acl);
> if (rc)
> return rc;
> - inode->i_ctime = current_time(inode);
> - mark_inode_dirty(inode);
> + update_mode = 1;
> }
> break;
> case ACL_TYPE_DEFAULT:
> @@ -105,8 +106,14 @@ static int __jfs_set_acl(tid_t tid, struct inode *inode, int type,
> out:
> kfree(value);
>
> - if (!rc)
> + if (!rc) {
> set_cached_acl(inode, type, acl);
> + if (update_mode) {
> + inode->i_mode = mode;
> + inode->i_ctime = current_time(inode);
> + mark_inode_dirty(inode);
> + }
> + }
>
> return rc;
> }
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Jfs-discussion mailing list
Jfs-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jfs-discussion
next prev parent reply other threads:[~2017-07-13 21:01 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 ` [PATCH 1/5] ext4: preserve i_mode if __ext4_set_acl() fails Ernesto A. Fernández
2017-07-17 15:33 ` 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 [this message]
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=9edc918e-619d-7b07-696d-c0184e42c58d@oracle.com \
--to=dave.kleikamp@oracle.com \
--cc=adilger.kernel@dilger.ca \
--cc=ernesto.mnd.fernandez@gmail.com \
--cc=jack@suse.com \
--cc=jfs-discussion@lists.sourceforge.net \
--cc=linux-ext4@vger.kernel.org \
--cc=reiserfs-devel@vger.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).