Skip to content

Commit

Permalink
Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/jack/linux-fs

Pull misc filesystem fixes from Jan Kara:
 "Several ACL related fixes for ext2, reiserfs, and hfsplus.

  And also one minor isofs cleanup"

* 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs:
  hfsplus: Don't clear SGID when inheriting ACLs
  isofs: Fix off-by-one in 'session' mount option parsing
  reiserfs: preserve i_mode if __reiserfs_set_acl() fails
  ext2: preserve i_mode if ext2_set_acl() fails
  ext2: Don't clear SGID when inheriting ACLs
  reiserfs: Don't clear SGID when inheriting ACLs
  • Loading branch information
Linus Torvalds committed Jul 20, 2017
2 parents 465b0db + 8496946 commit 791f2df
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 34 deletions.
43 changes: 29 additions & 14 deletions fs/ext2/acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,8 @@ ext2_get_acl(struct inode *inode, int type)
return acl;
}

/*
* inode->i_mutex: down
*/
int
ext2_set_acl(struct inode *inode, struct posix_acl *acl, int type)
static int
__ext2_set_acl(struct inode *inode, struct posix_acl *acl, int type)
{
int name_index;
void *value = NULL;
Expand All @@ -189,13 +186,6 @@ ext2_set_acl(struct inode *inode, struct posix_acl *acl, int type)
switch(type) {
case ACL_TYPE_ACCESS:
name_index = EXT2_XATTR_INDEX_POSIX_ACL_ACCESS;
if (acl) {
error = posix_acl_update_mode(inode, &inode->i_mode, &acl);
if (error)
return error;
inode->i_ctime = current_time(inode);
mark_inode_dirty(inode);
}
break;

case ACL_TYPE_DEFAULT:
Expand All @@ -221,6 +211,31 @@ ext2_set_acl(struct inode *inode, struct posix_acl *acl, int type)
return error;
}

/*
* inode->i_mutex: down
*/
int
ext2_set_acl(struct inode *inode, struct posix_acl *acl, int type)
{
int error;
int update_mode = 0;
umode_t mode = inode->i_mode;

if (type == ACL_TYPE_ACCESS && acl) {
error = posix_acl_update_mode(inode, &mode, &acl);
if (error)
return error;
update_mode = 1;
}
error = __ext2_set_acl(inode, acl, type);
if (!error && update_mode) {
inode->i_mode = mode;
inode->i_ctime = current_time(inode);
mark_inode_dirty(inode);
}
return error;
}

/*
* Initialize the ACLs of a new inode. Called from ext2_new_inode.
*
Expand All @@ -238,12 +253,12 @@ ext2_init_acl(struct inode *inode, struct inode *dir)
return error;

if (default_acl) {
error = ext2_set_acl(inode, default_acl, ACL_TYPE_DEFAULT);
error = __ext2_set_acl(inode, default_acl, ACL_TYPE_DEFAULT);
posix_acl_release(default_acl);
}
if (acl) {
if (!error)
error = ext2_set_acl(inode, acl, ACL_TYPE_ACCESS);
error = __ext2_set_acl(inode, acl, ACL_TYPE_ACCESS);
posix_acl_release(acl);
}
return error;
Expand Down
30 changes: 18 additions & 12 deletions fs/hfsplus/posix_acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ struct posix_acl *hfsplus_get_posix_acl(struct inode *inode, int type)
return acl;
}

int hfsplus_set_posix_acl(struct inode *inode, struct posix_acl *acl,
int type)
static int __hfsplus_set_posix_acl(struct inode *inode, struct posix_acl *acl,
int type)
{
int err;
char *xattr_name;
Expand All @@ -64,12 +64,6 @@ int hfsplus_set_posix_acl(struct inode *inode, struct posix_acl *acl,
switch (type) {
case ACL_TYPE_ACCESS:
xattr_name = XATTR_NAME_POSIX_ACL_ACCESS;
if (acl) {
err = posix_acl_update_mode(inode, &inode->i_mode, &acl);
if (err)
return err;
}
err = 0;
break;

case ACL_TYPE_DEFAULT:
Expand Down Expand Up @@ -105,6 +99,18 @@ int hfsplus_set_posix_acl(struct inode *inode, struct posix_acl *acl,
return err;
}

int hfsplus_set_posix_acl(struct inode *inode, struct posix_acl *acl, int type)
{
int err;

if (type == ACL_TYPE_ACCESS && acl) {
err = posix_acl_update_mode(inode, &inode->i_mode, &acl);
if (err)
return err;
}
return __hfsplus_set_posix_acl(inode, acl, type);
}

int hfsplus_init_posix_acl(struct inode *inode, struct inode *dir)
{
int err = 0;
Expand All @@ -122,15 +128,15 @@ int hfsplus_init_posix_acl(struct inode *inode, struct inode *dir)
return err;

if (default_acl) {
err = hfsplus_set_posix_acl(inode, default_acl,
ACL_TYPE_DEFAULT);
err = __hfsplus_set_posix_acl(inode, default_acl,
ACL_TYPE_DEFAULT);
posix_acl_release(default_acl);
}

if (acl) {
if (!err)
err = hfsplus_set_posix_acl(inode, acl,
ACL_TYPE_ACCESS);
err = __hfsplus_set_posix_acl(inode, acl,
ACL_TYPE_ACCESS);
posix_acl_release(acl);
}
return err;
Expand Down
8 changes: 6 additions & 2 deletions fs/isofs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,11 @@ static int parse_options(char *options, struct iso9660_options *popt)
if (match_int(&args[0], &option))
return 0;
n = option;
if (n > 99)
/*
* Track numbers are supposed to be in range 1-99, the
* mount option starts indexing at 0.
*/
if (n >= 99)
return 0;
popt->session = n + 1;
break;
Expand Down Expand Up @@ -543,7 +547,7 @@ static unsigned int isofs_get_last_session(struct super_block *sb, s32 session)

vol_desc_start=0;
ms_info.addr_format=CDROM_LBA;
if(session >= 0 && session <= 99) {
if (session > 0) {
struct cdrom_tocentry Te;
Te.cdte_track=session;
Te.cdte_format=CDROM_LBA;
Expand Down
17 changes: 11 additions & 6 deletions fs/reiserfs/xattr_acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ reiserfs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
struct reiserfs_transaction_handle th;
size_t jcreate_blocks;
int size = acl ? posix_acl_xattr_size(acl->a_count) : 0;

int update_mode = 0;
umode_t mode = inode->i_mode;

/*
* Pessimism: We can't assume that anything from the xattr root up
Expand All @@ -37,7 +38,16 @@ reiserfs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
error = journal_begin(&th, inode->i_sb, jcreate_blocks);
reiserfs_write_unlock(inode->i_sb);
if (error == 0) {
if (type == ACL_TYPE_ACCESS && acl) {
error = posix_acl_update_mode(inode, &mode, &acl);
if (error)
goto unlock;
update_mode = 1;
}
error = __reiserfs_set_acl(&th, inode, type, acl);
if (!error && update_mode)
inode->i_mode = mode;
unlock:
reiserfs_write_lock(inode->i_sb);
error2 = journal_end(&th);
reiserfs_write_unlock(inode->i_sb);
Expand Down Expand Up @@ -241,11 +251,6 @@ __reiserfs_set_acl(struct reiserfs_transaction_handle *th, struct inode *inode,
switch (type) {
case ACL_TYPE_ACCESS:
name = XATTR_NAME_POSIX_ACL_ACCESS;
if (acl) {
error = posix_acl_update_mode(inode, &inode->i_mode, &acl);
if (error)
return error;
}
break;
case ACL_TYPE_DEFAULT:
name = XATTR_NAME_POSIX_ACL_DEFAULT;
Expand Down

0 comments on commit 791f2df

Please sign in to comment.