Skip to content

Commit 791f2df

Browse files
committed
Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/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
2 parents 465b0db + 8496946 commit 791f2df

File tree

4 files changed

+64
-34
lines changed

4 files changed

+64
-34
lines changed

fs/ext2/acl.c

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,8 @@ ext2_get_acl(struct inode *inode, int type)
175175
return acl;
176176
}
177177

178-
/*
179-
* inode->i_mutex: down
180-
*/
181-
int
182-
ext2_set_acl(struct inode *inode, struct posix_acl *acl, int type)
178+
static int
179+
__ext2_set_acl(struct inode *inode, struct posix_acl *acl, int type)
183180
{
184181
int name_index;
185182
void *value = NULL;
@@ -189,13 +186,6 @@ ext2_set_acl(struct inode *inode, struct posix_acl *acl, int type)
189186
switch(type) {
190187
case ACL_TYPE_ACCESS:
191188
name_index = EXT2_XATTR_INDEX_POSIX_ACL_ACCESS;
192-
if (acl) {
193-
error = posix_acl_update_mode(inode, &inode->i_mode, &acl);
194-
if (error)
195-
return error;
196-
inode->i_ctime = current_time(inode);
197-
mark_inode_dirty(inode);
198-
}
199189
break;
200190

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

214+
/*
215+
* inode->i_mutex: down
216+
*/
217+
int
218+
ext2_set_acl(struct inode *inode, struct posix_acl *acl, int type)
219+
{
220+
int error;
221+
int update_mode = 0;
222+
umode_t mode = inode->i_mode;
223+
224+
if (type == ACL_TYPE_ACCESS && acl) {
225+
error = posix_acl_update_mode(inode, &mode, &acl);
226+
if (error)
227+
return error;
228+
update_mode = 1;
229+
}
230+
error = __ext2_set_acl(inode, acl, type);
231+
if (!error && update_mode) {
232+
inode->i_mode = mode;
233+
inode->i_ctime = current_time(inode);
234+
mark_inode_dirty(inode);
235+
}
236+
return error;
237+
}
238+
224239
/*
225240
* Initialize the ACLs of a new inode. Called from ext2_new_inode.
226241
*
@@ -238,12 +253,12 @@ ext2_init_acl(struct inode *inode, struct inode *dir)
238253
return error;
239254

240255
if (default_acl) {
241-
error = ext2_set_acl(inode, default_acl, ACL_TYPE_DEFAULT);
256+
error = __ext2_set_acl(inode, default_acl, ACL_TYPE_DEFAULT);
242257
posix_acl_release(default_acl);
243258
}
244259
if (acl) {
245260
if (!error)
246-
error = ext2_set_acl(inode, acl, ACL_TYPE_ACCESS);
261+
error = __ext2_set_acl(inode, acl, ACL_TYPE_ACCESS);
247262
posix_acl_release(acl);
248263
}
249264
return error;

fs/hfsplus/posix_acl.c

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ struct posix_acl *hfsplus_get_posix_acl(struct inode *inode, int type)
5151
return acl;
5252
}
5353

54-
int hfsplus_set_posix_acl(struct inode *inode, struct posix_acl *acl,
55-
int type)
54+
static int __hfsplus_set_posix_acl(struct inode *inode, struct posix_acl *acl,
55+
int type)
5656
{
5757
int err;
5858
char *xattr_name;
@@ -64,12 +64,6 @@ int hfsplus_set_posix_acl(struct inode *inode, struct posix_acl *acl,
6464
switch (type) {
6565
case ACL_TYPE_ACCESS:
6666
xattr_name = XATTR_NAME_POSIX_ACL_ACCESS;
67-
if (acl) {
68-
err = posix_acl_update_mode(inode, &inode->i_mode, &acl);
69-
if (err)
70-
return err;
71-
}
72-
err = 0;
7367
break;
7468

7569
case ACL_TYPE_DEFAULT:
@@ -105,6 +99,18 @@ int hfsplus_set_posix_acl(struct inode *inode, struct posix_acl *acl,
10599
return err;
106100
}
107101

102+
int hfsplus_set_posix_acl(struct inode *inode, struct posix_acl *acl, int type)
103+
{
104+
int err;
105+
106+
if (type == ACL_TYPE_ACCESS && acl) {
107+
err = posix_acl_update_mode(inode, &inode->i_mode, &acl);
108+
if (err)
109+
return err;
110+
}
111+
return __hfsplus_set_posix_acl(inode, acl, type);
112+
}
113+
108114
int hfsplus_init_posix_acl(struct inode *inode, struct inode *dir)
109115
{
110116
int err = 0;
@@ -122,15 +128,15 @@ int hfsplus_init_posix_acl(struct inode *inode, struct inode *dir)
122128
return err;
123129

124130
if (default_acl) {
125-
err = hfsplus_set_posix_acl(inode, default_acl,
126-
ACL_TYPE_DEFAULT);
131+
err = __hfsplus_set_posix_acl(inode, default_acl,
132+
ACL_TYPE_DEFAULT);
127133
posix_acl_release(default_acl);
128134
}
129135

130136
if (acl) {
131137
if (!err)
132-
err = hfsplus_set_posix_acl(inode, acl,
133-
ACL_TYPE_ACCESS);
138+
err = __hfsplus_set_posix_acl(inode, acl,
139+
ACL_TYPE_ACCESS);
134140
posix_acl_release(acl);
135141
}
136142
return err;

fs/isofs/inode.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,11 @@ static int parse_options(char *options, struct iso9660_options *popt)
410410
if (match_int(&args[0], &option))
411411
return 0;
412412
n = option;
413-
if (n > 99)
413+
/*
414+
* Track numbers are supposed to be in range 1-99, the
415+
* mount option starts indexing at 0.
416+
*/
417+
if (n >= 99)
414418
return 0;
415419
popt->session = n + 1;
416420
break;
@@ -543,7 +547,7 @@ static unsigned int isofs_get_last_session(struct super_block *sb, s32 session)
543547

544548
vol_desc_start=0;
545549
ms_info.addr_format=CDROM_LBA;
546-
if(session >= 0 && session <= 99) {
550+
if (session > 0) {
547551
struct cdrom_tocentry Te;
548552
Te.cdte_track=session;
549553
Te.cdte_format=CDROM_LBA;

fs/reiserfs/xattr_acl.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ reiserfs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
2323
struct reiserfs_transaction_handle th;
2424
size_t jcreate_blocks;
2525
int size = acl ? posix_acl_xattr_size(acl->a_count) : 0;
26-
26+
int update_mode = 0;
27+
umode_t mode = inode->i_mode;
2728

2829
/*
2930
* Pessimism: We can't assume that anything from the xattr root up
@@ -37,7 +38,16 @@ reiserfs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
3738
error = journal_begin(&th, inode->i_sb, jcreate_blocks);
3839
reiserfs_write_unlock(inode->i_sb);
3940
if (error == 0) {
41+
if (type == ACL_TYPE_ACCESS && acl) {
42+
error = posix_acl_update_mode(inode, &mode, &acl);
43+
if (error)
44+
goto unlock;
45+
update_mode = 1;
46+
}
4047
error = __reiserfs_set_acl(&th, inode, type, acl);
48+
if (!error && update_mode)
49+
inode->i_mode = mode;
50+
unlock:
4151
reiserfs_write_lock(inode->i_sb);
4252
error2 = journal_end(&th);
4353
reiserfs_write_unlock(inode->i_sb);
@@ -241,11 +251,6 @@ __reiserfs_set_acl(struct reiserfs_transaction_handle *th, struct inode *inode,
241251
switch (type) {
242252
case ACL_TYPE_ACCESS:
243253
name = XATTR_NAME_POSIX_ACL_ACCESS;
244-
if (acl) {
245-
error = posix_acl_update_mode(inode, &inode->i_mode, &acl);
246-
if (error)
247-
return error;
248-
}
249254
break;
250255
case ACL_TYPE_DEFAULT:
251256
name = XATTR_NAME_POSIX_ACL_DEFAULT;

0 commit comments

Comments
 (0)