diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2017-07-20 13:41:12 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-07-20 13:41:12 -0400 |
commit | 791f2df39b8248490ab41022939debaa82b96028 (patch) | |
tree | 99fd6e5536433d7758f087635e67e78a33749ae4 /fs | |
parent | 465b0dbb38a02c449c62563ce0995e741c0ebe18 (diff) | |
parent | 84969465ddc4f8aeb3b993123b571aa01c5f2683 (diff) |
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
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ext2/acl.c | 43 | ||||
-rw-r--r-- | fs/hfsplus/posix_acl.c | 30 | ||||
-rw-r--r-- | fs/isofs/inode.c | 8 | ||||
-rw-r--r-- | fs/reiserfs/xattr_acl.c | 17 |
4 files changed, 64 insertions, 34 deletions
diff --git a/fs/ext2/acl.c b/fs/ext2/acl.c index 79dafa71effd..51f0aea70cb4 100644 --- a/fs/ext2/acl.c +++ b/fs/ext2/acl.c | |||
@@ -175,11 +175,8 @@ ext2_get_acl(struct inode *inode, int type) | |||
175 | return acl; | 175 | return acl; |
176 | } | 176 | } |
177 | 177 | ||
178 | /* | 178 | static int |
179 | * inode->i_mutex: down | 179 | __ext2_set_acl(struct inode *inode, struct posix_acl *acl, int type) |
180 | */ | ||
181 | int | ||
182 | ext2_set_acl(struct inode *inode, struct posix_acl *acl, int type) | ||
183 | { | 180 | { |
184 | int name_index; | 181 | int name_index; |
185 | void *value = NULL; | 182 | void *value = NULL; |
@@ -189,13 +186,6 @@ ext2_set_acl(struct inode *inode, struct posix_acl *acl, int type) | |||
189 | switch(type) { | 186 | switch(type) { |
190 | case ACL_TYPE_ACCESS: | 187 | case ACL_TYPE_ACCESS: |
191 | name_index = EXT2_XATTR_INDEX_POSIX_ACL_ACCESS; | 188 | 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 | } | ||
199 | break; | 189 | break; |
200 | 190 | ||
201 | case ACL_TYPE_DEFAULT: | 191 | case ACL_TYPE_DEFAULT: |
@@ -222,6 +212,31 @@ ext2_set_acl(struct inode *inode, struct posix_acl *acl, int type) | |||
222 | } | 212 | } |
223 | 213 | ||
224 | /* | 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 | |||
239 | /* | ||
225 | * Initialize the ACLs of a new inode. Called from ext2_new_inode. | 240 | * Initialize the ACLs of a new inode. Called from ext2_new_inode. |
226 | * | 241 | * |
227 | * dir->i_mutex: down | 242 | * dir->i_mutex: down |
@@ -238,12 +253,12 @@ ext2_init_acl(struct inode *inode, struct inode *dir) | |||
238 | return error; | 253 | return error; |
239 | 254 | ||
240 | if (default_acl) { | 255 | 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); |
242 | posix_acl_release(default_acl); | 257 | posix_acl_release(default_acl); |
243 | } | 258 | } |
244 | if (acl) { | 259 | if (acl) { |
245 | if (!error) | 260 | if (!error) |
246 | error = ext2_set_acl(inode, acl, ACL_TYPE_ACCESS); | 261 | error = __ext2_set_acl(inode, acl, ACL_TYPE_ACCESS); |
247 | posix_acl_release(acl); | 262 | posix_acl_release(acl); |
248 | } | 263 | } |
249 | return error; | 264 | return error; |
diff --git a/fs/hfsplus/posix_acl.c b/fs/hfsplus/posix_acl.c index 9b92058a1240..6bb5d7c42888 100644 --- a/fs/hfsplus/posix_acl.c +++ b/fs/hfsplus/posix_acl.c | |||
@@ -51,8 +51,8 @@ struct posix_acl *hfsplus_get_posix_acl(struct inode *inode, int type) | |||
51 | return acl; | 51 | return acl; |
52 | } | 52 | } |
53 | 53 | ||
54 | int hfsplus_set_posix_acl(struct inode *inode, struct posix_acl *acl, | 54 | static int __hfsplus_set_posix_acl(struct inode *inode, struct posix_acl *acl, |
55 | int type) | 55 | int type) |
56 | { | 56 | { |
57 | int err; | 57 | int err; |
58 | char *xattr_name; | 58 | char *xattr_name; |
@@ -64,12 +64,6 @@ int hfsplus_set_posix_acl(struct inode *inode, struct posix_acl *acl, | |||
64 | switch (type) { | 64 | switch (type) { |
65 | case ACL_TYPE_ACCESS: | 65 | case ACL_TYPE_ACCESS: |
66 | xattr_name = XATTR_NAME_POSIX_ACL_ACCESS; | 66 | 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; | ||
73 | break; | 67 | break; |
74 | 68 | ||
75 | case ACL_TYPE_DEFAULT: | 69 | case ACL_TYPE_DEFAULT: |
@@ -105,6 +99,18 @@ end_set_acl: | |||
105 | return err; | 99 | return err; |
106 | } | 100 | } |
107 | 101 | ||
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 | |||
108 | int hfsplus_init_posix_acl(struct inode *inode, struct inode *dir) | 114 | int hfsplus_init_posix_acl(struct inode *inode, struct inode *dir) |
109 | { | 115 | { |
110 | int err = 0; | 116 | int err = 0; |
@@ -122,15 +128,15 @@ int hfsplus_init_posix_acl(struct inode *inode, struct inode *dir) | |||
122 | return err; | 128 | return err; |
123 | 129 | ||
124 | if (default_acl) { | 130 | if (default_acl) { |
125 | err = hfsplus_set_posix_acl(inode, default_acl, | 131 | err = __hfsplus_set_posix_acl(inode, default_acl, |
126 | ACL_TYPE_DEFAULT); | 132 | ACL_TYPE_DEFAULT); |
127 | posix_acl_release(default_acl); | 133 | posix_acl_release(default_acl); |
128 | } | 134 | } |
129 | 135 | ||
130 | if (acl) { | 136 | if (acl) { |
131 | if (!err) | 137 | if (!err) |
132 | err = hfsplus_set_posix_acl(inode, acl, | 138 | err = __hfsplus_set_posix_acl(inode, acl, |
133 | ACL_TYPE_ACCESS); | 139 | ACL_TYPE_ACCESS); |
134 | posix_acl_release(acl); | 140 | posix_acl_release(acl); |
135 | } | 141 | } |
136 | return err; | 142 | return err; |
diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c index 8cf898a59730..217a5e7815da 100644 --- a/fs/isofs/inode.c +++ b/fs/isofs/inode.c | |||
@@ -410,7 +410,11 @@ static int parse_options(char *options, struct iso9660_options *popt) | |||
410 | if (match_int(&args[0], &option)) | 410 | if (match_int(&args[0], &option)) |
411 | return 0; | 411 | return 0; |
412 | n = option; | 412 | 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) | ||
414 | return 0; | 418 | return 0; |
415 | popt->session = n + 1; | 419 | popt->session = n + 1; |
416 | break; | 420 | break; |
@@ -543,7 +547,7 @@ static unsigned int isofs_get_last_session(struct super_block *sb, s32 session) | |||
543 | 547 | ||
544 | vol_desc_start=0; | 548 | vol_desc_start=0; |
545 | ms_info.addr_format=CDROM_LBA; | 549 | ms_info.addr_format=CDROM_LBA; |
546 | if(session >= 0 && session <= 99) { | 550 | if (session > 0) { |
547 | struct cdrom_tocentry Te; | 551 | struct cdrom_tocentry Te; |
548 | Te.cdte_track=session; | 552 | Te.cdte_track=session; |
549 | Te.cdte_format=CDROM_LBA; | 553 | Te.cdte_format=CDROM_LBA; |
diff --git a/fs/reiserfs/xattr_acl.c b/fs/reiserfs/xattr_acl.c index 3d2256a425ee..54415f0e3d18 100644 --- a/fs/reiserfs/xattr_acl.c +++ b/fs/reiserfs/xattr_acl.c | |||
@@ -23,7 +23,8 @@ reiserfs_set_acl(struct inode *inode, struct posix_acl *acl, int type) | |||
23 | struct reiserfs_transaction_handle th; | 23 | struct reiserfs_transaction_handle th; |
24 | size_t jcreate_blocks; | 24 | size_t jcreate_blocks; |
25 | int size = acl ? posix_acl_xattr_size(acl->a_count) : 0; | 25 | int size = acl ? posix_acl_xattr_size(acl->a_count) : 0; |
26 | 26 | int update_mode = 0; | |
27 | umode_t mode = inode->i_mode; | ||
27 | 28 | ||
28 | /* | 29 | /* |
29 | * Pessimism: We can't assume that anything from the xattr root up | 30 | * 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) | |||
37 | error = journal_begin(&th, inode->i_sb, jcreate_blocks); | 38 | error = journal_begin(&th, inode->i_sb, jcreate_blocks); |
38 | reiserfs_write_unlock(inode->i_sb); | 39 | reiserfs_write_unlock(inode->i_sb); |
39 | if (error == 0) { | 40 | 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 | } | ||
40 | error = __reiserfs_set_acl(&th, inode, type, acl); | 47 | error = __reiserfs_set_acl(&th, inode, type, acl); |
48 | if (!error && update_mode) | ||
49 | inode->i_mode = mode; | ||
50 | unlock: | ||
41 | reiserfs_write_lock(inode->i_sb); | 51 | reiserfs_write_lock(inode->i_sb); |
42 | error2 = journal_end(&th); | 52 | error2 = journal_end(&th); |
43 | reiserfs_write_unlock(inode->i_sb); | 53 | reiserfs_write_unlock(inode->i_sb); |
@@ -241,11 +251,6 @@ __reiserfs_set_acl(struct reiserfs_transaction_handle *th, struct inode *inode, | |||
241 | switch (type) { | 251 | switch (type) { |
242 | case ACL_TYPE_ACCESS: | 252 | case ACL_TYPE_ACCESS: |
243 | name = XATTR_NAME_POSIX_ACL_ACCESS; | 253 | 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 | } | ||
249 | break; | 254 | break; |
250 | case ACL_TYPE_DEFAULT: | 255 | case ACL_TYPE_DEFAULT: |
251 | name = XATTR_NAME_POSIX_ACL_DEFAULT; | 256 | name = XATTR_NAME_POSIX_ACL_DEFAULT; |