diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-09-09 23:04:54 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-09-09 23:04:54 -0400 |
commit | 526b678093a8a4bcf1ffffbe17bcf21c057eddf5 (patch) | |
tree | 6c0a5b35783f1e89406b667c9c525571d1b4d24e | |
parent | 752015d1b0683a8c623ebfe4c62893413e9b30d3 (diff) | |
parent | 18f4c644773bc8de1fd9c5182b30c231aafb94ef (diff) |
Merge branch 'lookup-permissions-cleanup'
* lookup-permissions-cleanup:
jffs2/jfs/xfs: switch over to 'check_acl' rather than 'permission()'
ext[234]: move over to 'check_acl' permission model
shmfs: use 'check_acl' instead of 'permission'
Make 'check_acl()' a first-class filesystem op
Simplify exec_permission_lite(), part 3
Simplify exec_permission_lite() further
Simplify exec_permission_lite() logic
Do not call 'ima_path_check()' for each path component
-rw-r--r-- | fs/ext2/acl.c | 8 | ||||
-rw-r--r-- | fs/ext2/acl.h | 4 | ||||
-rw-r--r-- | fs/ext2/file.c | 2 | ||||
-rw-r--r-- | fs/ext2/namei.c | 4 | ||||
-rw-r--r-- | fs/ext3/acl.c | 8 | ||||
-rw-r--r-- | fs/ext3/acl.h | 4 | ||||
-rw-r--r-- | fs/ext3/file.c | 2 | ||||
-rw-r--r-- | fs/ext3/namei.c | 4 | ||||
-rw-r--r-- | fs/ext4/acl.c | 8 | ||||
-rw-r--r-- | fs/ext4/acl.h | 4 | ||||
-rw-r--r-- | fs/ext4/file.c | 2 | ||||
-rw-r--r-- | fs/ext4/namei.c | 4 | ||||
-rw-r--r-- | fs/jffs2/acl.c | 7 | ||||
-rw-r--r-- | fs/jffs2/acl.h | 4 | ||||
-rw-r--r-- | fs/jffs2/dir.c | 2 | ||||
-rw-r--r-- | fs/jffs2/file.c | 2 | ||||
-rw-r--r-- | fs/jffs2/symlink.c | 2 | ||||
-rw-r--r-- | fs/jfs/acl.c | 7 | ||||
-rw-r--r-- | fs/jfs/file.c | 2 | ||||
-rw-r--r-- | fs/jfs/jfs_acl.h | 2 | ||||
-rw-r--r-- | fs/jfs/namei.c | 2 | ||||
-rw-r--r-- | fs/namei.c | 82 | ||||
-rw-r--r-- | fs/xfs/linux-2.6/xfs_iops.c | 16 | ||||
-rw-r--r-- | include/linux/fs.h | 1 | ||||
-rw-r--r-- | include/linux/shmem_fs.h | 2 | ||||
-rw-r--r-- | mm/shmem.c | 6 | ||||
-rw-r--r-- | mm/shmem_acl.c | 11 |
27 files changed, 79 insertions, 123 deletions
diff --git a/fs/ext2/acl.c b/fs/ext2/acl.c index d636e1297cad..a63d44256a70 100644 --- a/fs/ext2/acl.c +++ b/fs/ext2/acl.c | |||
@@ -230,7 +230,7 @@ ext2_set_acl(struct inode *inode, int type, struct posix_acl *acl) | |||
230 | return error; | 230 | return error; |
231 | } | 231 | } |
232 | 232 | ||
233 | static int | 233 | int |
234 | ext2_check_acl(struct inode *inode, int mask) | 234 | ext2_check_acl(struct inode *inode, int mask) |
235 | { | 235 | { |
236 | struct posix_acl *acl = ext2_get_acl(inode, ACL_TYPE_ACCESS); | 236 | struct posix_acl *acl = ext2_get_acl(inode, ACL_TYPE_ACCESS); |
@@ -246,12 +246,6 @@ ext2_check_acl(struct inode *inode, int mask) | |||
246 | return -EAGAIN; | 246 | return -EAGAIN; |
247 | } | 247 | } |
248 | 248 | ||
249 | int | ||
250 | ext2_permission(struct inode *inode, int mask) | ||
251 | { | ||
252 | return generic_permission(inode, mask, ext2_check_acl); | ||
253 | } | ||
254 | |||
255 | /* | 249 | /* |
256 | * Initialize the ACLs of a new inode. Called from ext2_new_inode. | 250 | * Initialize the ACLs of a new inode. Called from ext2_new_inode. |
257 | * | 251 | * |
diff --git a/fs/ext2/acl.h b/fs/ext2/acl.h index ecefe478898f..3ff6cbb9ac44 100644 --- a/fs/ext2/acl.h +++ b/fs/ext2/acl.h | |||
@@ -54,13 +54,13 @@ static inline int ext2_acl_count(size_t size) | |||
54 | #ifdef CONFIG_EXT2_FS_POSIX_ACL | 54 | #ifdef CONFIG_EXT2_FS_POSIX_ACL |
55 | 55 | ||
56 | /* acl.c */ | 56 | /* acl.c */ |
57 | extern int ext2_permission (struct inode *, int); | 57 | extern int ext2_check_acl (struct inode *, int); |
58 | extern int ext2_acl_chmod (struct inode *); | 58 | extern int ext2_acl_chmod (struct inode *); |
59 | extern int ext2_init_acl (struct inode *, struct inode *); | 59 | extern int ext2_init_acl (struct inode *, struct inode *); |
60 | 60 | ||
61 | #else | 61 | #else |
62 | #include <linux/sched.h> | 62 | #include <linux/sched.h> |
63 | #define ext2_permission NULL | 63 | #define ext2_check_acl NULL |
64 | #define ext2_get_acl NULL | 64 | #define ext2_get_acl NULL |
65 | #define ext2_set_acl NULL | 65 | #define ext2_set_acl NULL |
66 | 66 | ||
diff --git a/fs/ext2/file.c b/fs/ext2/file.c index 2b9e47dc9222..a2f3afd1a1c1 100644 --- a/fs/ext2/file.c +++ b/fs/ext2/file.c | |||
@@ -85,6 +85,6 @@ const struct inode_operations ext2_file_inode_operations = { | |||
85 | .removexattr = generic_removexattr, | 85 | .removexattr = generic_removexattr, |
86 | #endif | 86 | #endif |
87 | .setattr = ext2_setattr, | 87 | .setattr = ext2_setattr, |
88 | .permission = ext2_permission, | 88 | .check_acl = ext2_check_acl, |
89 | .fiemap = ext2_fiemap, | 89 | .fiemap = ext2_fiemap, |
90 | }; | 90 | }; |
diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c index 78d9b925fc94..23701f289e98 100644 --- a/fs/ext2/namei.c +++ b/fs/ext2/namei.c | |||
@@ -400,7 +400,7 @@ const struct inode_operations ext2_dir_inode_operations = { | |||
400 | .removexattr = generic_removexattr, | 400 | .removexattr = generic_removexattr, |
401 | #endif | 401 | #endif |
402 | .setattr = ext2_setattr, | 402 | .setattr = ext2_setattr, |
403 | .permission = ext2_permission, | 403 | .check_acl = ext2_check_acl, |
404 | }; | 404 | }; |
405 | 405 | ||
406 | const struct inode_operations ext2_special_inode_operations = { | 406 | const struct inode_operations ext2_special_inode_operations = { |
@@ -411,5 +411,5 @@ const struct inode_operations ext2_special_inode_operations = { | |||
411 | .removexattr = generic_removexattr, | 411 | .removexattr = generic_removexattr, |
412 | #endif | 412 | #endif |
413 | .setattr = ext2_setattr, | 413 | .setattr = ext2_setattr, |
414 | .permission = ext2_permission, | 414 | .check_acl = ext2_check_acl, |
415 | }; | 415 | }; |
diff --git a/fs/ext3/acl.c b/fs/ext3/acl.c index e167bae37ef0..c9b0df376b5f 100644 --- a/fs/ext3/acl.c +++ b/fs/ext3/acl.c | |||
@@ -238,7 +238,7 @@ ext3_set_acl(handle_t *handle, struct inode *inode, int type, | |||
238 | return error; | 238 | return error; |
239 | } | 239 | } |
240 | 240 | ||
241 | static int | 241 | int |
242 | ext3_check_acl(struct inode *inode, int mask) | 242 | ext3_check_acl(struct inode *inode, int mask) |
243 | { | 243 | { |
244 | struct posix_acl *acl = ext3_get_acl(inode, ACL_TYPE_ACCESS); | 244 | struct posix_acl *acl = ext3_get_acl(inode, ACL_TYPE_ACCESS); |
@@ -254,12 +254,6 @@ ext3_check_acl(struct inode *inode, int mask) | |||
254 | return -EAGAIN; | 254 | return -EAGAIN; |
255 | } | 255 | } |
256 | 256 | ||
257 | int | ||
258 | ext3_permission(struct inode *inode, int mask) | ||
259 | { | ||
260 | return generic_permission(inode, mask, ext3_check_acl); | ||
261 | } | ||
262 | |||
263 | /* | 257 | /* |
264 | * Initialize the ACLs of a new inode. Called from ext3_new_inode. | 258 | * Initialize the ACLs of a new inode. Called from ext3_new_inode. |
265 | * | 259 | * |
diff --git a/fs/ext3/acl.h b/fs/ext3/acl.h index 07d15a3a5969..597334626de9 100644 --- a/fs/ext3/acl.h +++ b/fs/ext3/acl.h | |||
@@ -54,13 +54,13 @@ static inline int ext3_acl_count(size_t size) | |||
54 | #ifdef CONFIG_EXT3_FS_POSIX_ACL | 54 | #ifdef CONFIG_EXT3_FS_POSIX_ACL |
55 | 55 | ||
56 | /* acl.c */ | 56 | /* acl.c */ |
57 | extern int ext3_permission (struct inode *, int); | 57 | extern int ext3_check_acl (struct inode *, int); |
58 | extern int ext3_acl_chmod (struct inode *); | 58 | extern int ext3_acl_chmod (struct inode *); |
59 | extern int ext3_init_acl (handle_t *, struct inode *, struct inode *); | 59 | extern int ext3_init_acl (handle_t *, struct inode *, struct inode *); |
60 | 60 | ||
61 | #else /* CONFIG_EXT3_FS_POSIX_ACL */ | 61 | #else /* CONFIG_EXT3_FS_POSIX_ACL */ |
62 | #include <linux/sched.h> | 62 | #include <linux/sched.h> |
63 | #define ext3_permission NULL | 63 | #define ext3_check_acl NULL |
64 | 64 | ||
65 | static inline int | 65 | static inline int |
66 | ext3_acl_chmod(struct inode *inode) | 66 | ext3_acl_chmod(struct inode *inode) |
diff --git a/fs/ext3/file.c b/fs/ext3/file.c index 5b49704b231b..299253214789 100644 --- a/fs/ext3/file.c +++ b/fs/ext3/file.c | |||
@@ -137,7 +137,7 @@ const struct inode_operations ext3_file_inode_operations = { | |||
137 | .listxattr = ext3_listxattr, | 137 | .listxattr = ext3_listxattr, |
138 | .removexattr = generic_removexattr, | 138 | .removexattr = generic_removexattr, |
139 | #endif | 139 | #endif |
140 | .permission = ext3_permission, | 140 | .check_acl = ext3_check_acl, |
141 | .fiemap = ext3_fiemap, | 141 | .fiemap = ext3_fiemap, |
142 | }; | 142 | }; |
143 | 143 | ||
diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c index 6ff7b9730234..aad6400c9b77 100644 --- a/fs/ext3/namei.c +++ b/fs/ext3/namei.c | |||
@@ -2445,7 +2445,7 @@ const struct inode_operations ext3_dir_inode_operations = { | |||
2445 | .listxattr = ext3_listxattr, | 2445 | .listxattr = ext3_listxattr, |
2446 | .removexattr = generic_removexattr, | 2446 | .removexattr = generic_removexattr, |
2447 | #endif | 2447 | #endif |
2448 | .permission = ext3_permission, | 2448 | .check_acl = ext3_check_acl, |
2449 | }; | 2449 | }; |
2450 | 2450 | ||
2451 | const struct inode_operations ext3_special_inode_operations = { | 2451 | const struct inode_operations ext3_special_inode_operations = { |
@@ -2456,5 +2456,5 @@ const struct inode_operations ext3_special_inode_operations = { | |||
2456 | .listxattr = ext3_listxattr, | 2456 | .listxattr = ext3_listxattr, |
2457 | .removexattr = generic_removexattr, | 2457 | .removexattr = generic_removexattr, |
2458 | #endif | 2458 | #endif |
2459 | .permission = ext3_permission, | 2459 | .check_acl = ext3_check_acl, |
2460 | }; | 2460 | }; |
diff --git a/fs/ext4/acl.c b/fs/ext4/acl.c index f6d8967149ca..0df88b2a69b0 100644 --- a/fs/ext4/acl.c +++ b/fs/ext4/acl.c | |||
@@ -236,7 +236,7 @@ ext4_set_acl(handle_t *handle, struct inode *inode, int type, | |||
236 | return error; | 236 | return error; |
237 | } | 237 | } |
238 | 238 | ||
239 | static int | 239 | int |
240 | ext4_check_acl(struct inode *inode, int mask) | 240 | ext4_check_acl(struct inode *inode, int mask) |
241 | { | 241 | { |
242 | struct posix_acl *acl = ext4_get_acl(inode, ACL_TYPE_ACCESS); | 242 | struct posix_acl *acl = ext4_get_acl(inode, ACL_TYPE_ACCESS); |
@@ -252,12 +252,6 @@ ext4_check_acl(struct inode *inode, int mask) | |||
252 | return -EAGAIN; | 252 | return -EAGAIN; |
253 | } | 253 | } |
254 | 254 | ||
255 | int | ||
256 | ext4_permission(struct inode *inode, int mask) | ||
257 | { | ||
258 | return generic_permission(inode, mask, ext4_check_acl); | ||
259 | } | ||
260 | |||
261 | /* | 255 | /* |
262 | * Initialize the ACLs of a new inode. Called from ext4_new_inode. | 256 | * Initialize the ACLs of a new inode. Called from ext4_new_inode. |
263 | * | 257 | * |
diff --git a/fs/ext4/acl.h b/fs/ext4/acl.h index 949789d2bba6..9d843d5deac4 100644 --- a/fs/ext4/acl.h +++ b/fs/ext4/acl.h | |||
@@ -54,13 +54,13 @@ static inline int ext4_acl_count(size_t size) | |||
54 | #ifdef CONFIG_EXT4_FS_POSIX_ACL | 54 | #ifdef CONFIG_EXT4_FS_POSIX_ACL |
55 | 55 | ||
56 | /* acl.c */ | 56 | /* acl.c */ |
57 | extern int ext4_permission(struct inode *, int); | 57 | extern int ext4_check_acl(struct inode *, int); |
58 | extern int ext4_acl_chmod(struct inode *); | 58 | extern int ext4_acl_chmod(struct inode *); |
59 | extern int ext4_init_acl(handle_t *, struct inode *, struct inode *); | 59 | extern int ext4_init_acl(handle_t *, struct inode *, struct inode *); |
60 | 60 | ||
61 | #else /* CONFIG_EXT4_FS_POSIX_ACL */ | 61 | #else /* CONFIG_EXT4_FS_POSIX_ACL */ |
62 | #include <linux/sched.h> | 62 | #include <linux/sched.h> |
63 | #define ext4_permission NULL | 63 | #define ext4_check_acl NULL |
64 | 64 | ||
65 | static inline int | 65 | static inline int |
66 | ext4_acl_chmod(struct inode *inode) | 66 | ext4_acl_chmod(struct inode *inode) |
diff --git a/fs/ext4/file.c b/fs/ext4/file.c index 3f1873fef1c6..27f3c5354c0e 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c | |||
@@ -207,7 +207,7 @@ const struct inode_operations ext4_file_inode_operations = { | |||
207 | .listxattr = ext4_listxattr, | 207 | .listxattr = ext4_listxattr, |
208 | .removexattr = generic_removexattr, | 208 | .removexattr = generic_removexattr, |
209 | #endif | 209 | #endif |
210 | .permission = ext4_permission, | 210 | .check_acl = ext4_check_acl, |
211 | .fallocate = ext4_fallocate, | 211 | .fallocate = ext4_fallocate, |
212 | .fiemap = ext4_fiemap, | 212 | .fiemap = ext4_fiemap, |
213 | }; | 213 | }; |
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index de04013d16ff..114abe5d2c1d 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c | |||
@@ -2536,7 +2536,7 @@ const struct inode_operations ext4_dir_inode_operations = { | |||
2536 | .listxattr = ext4_listxattr, | 2536 | .listxattr = ext4_listxattr, |
2537 | .removexattr = generic_removexattr, | 2537 | .removexattr = generic_removexattr, |
2538 | #endif | 2538 | #endif |
2539 | .permission = ext4_permission, | 2539 | .check_acl = ext4_check_acl, |
2540 | .fiemap = ext4_fiemap, | 2540 | .fiemap = ext4_fiemap, |
2541 | }; | 2541 | }; |
2542 | 2542 | ||
@@ -2548,5 +2548,5 @@ const struct inode_operations ext4_special_inode_operations = { | |||
2548 | .listxattr = ext4_listxattr, | 2548 | .listxattr = ext4_listxattr, |
2549 | .removexattr = generic_removexattr, | 2549 | .removexattr = generic_removexattr, |
2550 | #endif | 2550 | #endif |
2551 | .permission = ext4_permission, | 2551 | .check_acl = ext4_check_acl, |
2552 | }; | 2552 | }; |
diff --git a/fs/jffs2/acl.c b/fs/jffs2/acl.c index 8fcb6239218e..7edb62e97419 100644 --- a/fs/jffs2/acl.c +++ b/fs/jffs2/acl.c | |||
@@ -258,7 +258,7 @@ static int jffs2_set_acl(struct inode *inode, int type, struct posix_acl *acl) | |||
258 | return rc; | 258 | return rc; |
259 | } | 259 | } |
260 | 260 | ||
261 | static int jffs2_check_acl(struct inode *inode, int mask) | 261 | int jffs2_check_acl(struct inode *inode, int mask) |
262 | { | 262 | { |
263 | struct posix_acl *acl; | 263 | struct posix_acl *acl; |
264 | int rc; | 264 | int rc; |
@@ -274,11 +274,6 @@ static int jffs2_check_acl(struct inode *inode, int mask) | |||
274 | return -EAGAIN; | 274 | return -EAGAIN; |
275 | } | 275 | } |
276 | 276 | ||
277 | int jffs2_permission(struct inode *inode, int mask) | ||
278 | { | ||
279 | return generic_permission(inode, mask, jffs2_check_acl); | ||
280 | } | ||
281 | |||
282 | int jffs2_init_acl_pre(struct inode *dir_i, struct inode *inode, int *i_mode) | 277 | int jffs2_init_acl_pre(struct inode *dir_i, struct inode *inode, int *i_mode) |
283 | { | 278 | { |
284 | struct posix_acl *acl, *clone; | 279 | struct posix_acl *acl, *clone; |
diff --git a/fs/jffs2/acl.h b/fs/jffs2/acl.h index fc929f2a14f6..f0ba63e3c36b 100644 --- a/fs/jffs2/acl.h +++ b/fs/jffs2/acl.h | |||
@@ -26,7 +26,7 @@ struct jffs2_acl_header { | |||
26 | 26 | ||
27 | #ifdef CONFIG_JFFS2_FS_POSIX_ACL | 27 | #ifdef CONFIG_JFFS2_FS_POSIX_ACL |
28 | 28 | ||
29 | extern int jffs2_permission(struct inode *, int); | 29 | extern int jffs2_check_acl(struct inode *, int); |
30 | extern int jffs2_acl_chmod(struct inode *); | 30 | extern int jffs2_acl_chmod(struct inode *); |
31 | extern int jffs2_init_acl_pre(struct inode *, struct inode *, int *); | 31 | extern int jffs2_init_acl_pre(struct inode *, struct inode *, int *); |
32 | extern int jffs2_init_acl_post(struct inode *); | 32 | extern int jffs2_init_acl_post(struct inode *); |
@@ -36,7 +36,7 @@ extern struct xattr_handler jffs2_acl_default_xattr_handler; | |||
36 | 36 | ||
37 | #else | 37 | #else |
38 | 38 | ||
39 | #define jffs2_permission (NULL) | 39 | #define jffs2_check_acl (NULL) |
40 | #define jffs2_acl_chmod(inode) (0) | 40 | #define jffs2_acl_chmod(inode) (0) |
41 | #define jffs2_init_acl_pre(dir_i,inode,mode) (0) | 41 | #define jffs2_init_acl_pre(dir_i,inode,mode) (0) |
42 | #define jffs2_init_acl_post(inode) (0) | 42 | #define jffs2_init_acl_post(inode) (0) |
diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c index 6f60cc910f4c..7aa4417e085f 100644 --- a/fs/jffs2/dir.c +++ b/fs/jffs2/dir.c | |||
@@ -55,7 +55,7 @@ const struct inode_operations jffs2_dir_inode_operations = | |||
55 | .rmdir = jffs2_rmdir, | 55 | .rmdir = jffs2_rmdir, |
56 | .mknod = jffs2_mknod, | 56 | .mknod = jffs2_mknod, |
57 | .rename = jffs2_rename, | 57 | .rename = jffs2_rename, |
58 | .permission = jffs2_permission, | 58 | .check_acl = jffs2_check_acl, |
59 | .setattr = jffs2_setattr, | 59 | .setattr = jffs2_setattr, |
60 | .setxattr = jffs2_setxattr, | 60 | .setxattr = jffs2_setxattr, |
61 | .getxattr = jffs2_getxattr, | 61 | .getxattr = jffs2_getxattr, |
diff --git a/fs/jffs2/file.c b/fs/jffs2/file.c index 23c947539864..b7b74e299142 100644 --- a/fs/jffs2/file.c +++ b/fs/jffs2/file.c | |||
@@ -56,7 +56,7 @@ const struct file_operations jffs2_file_operations = | |||
56 | 56 | ||
57 | const struct inode_operations jffs2_file_inode_operations = | 57 | const struct inode_operations jffs2_file_inode_operations = |
58 | { | 58 | { |
59 | .permission = jffs2_permission, | 59 | .check_acl = jffs2_check_acl, |
60 | .setattr = jffs2_setattr, | 60 | .setattr = jffs2_setattr, |
61 | .setxattr = jffs2_setxattr, | 61 | .setxattr = jffs2_setxattr, |
62 | .getxattr = jffs2_getxattr, | 62 | .getxattr = jffs2_getxattr, |
diff --git a/fs/jffs2/symlink.c b/fs/jffs2/symlink.c index b7339c3b6ad9..4ec11e8bda8c 100644 --- a/fs/jffs2/symlink.c +++ b/fs/jffs2/symlink.c | |||
@@ -21,7 +21,7 @@ const struct inode_operations jffs2_symlink_inode_operations = | |||
21 | { | 21 | { |
22 | .readlink = generic_readlink, | 22 | .readlink = generic_readlink, |
23 | .follow_link = jffs2_follow_link, | 23 | .follow_link = jffs2_follow_link, |
24 | .permission = jffs2_permission, | 24 | .check_acl = jffs2_check_acl, |
25 | .setattr = jffs2_setattr, | 25 | .setattr = jffs2_setattr, |
26 | .setxattr = jffs2_setxattr, | 26 | .setxattr = jffs2_setxattr, |
27 | .getxattr = jffs2_getxattr, | 27 | .getxattr = jffs2_getxattr, |
diff --git a/fs/jfs/acl.c b/fs/jfs/acl.c index a29c7c3e3fb8..d66477c34306 100644 --- a/fs/jfs/acl.c +++ b/fs/jfs/acl.c | |||
@@ -114,7 +114,7 @@ out: | |||
114 | return rc; | 114 | return rc; |
115 | } | 115 | } |
116 | 116 | ||
117 | static int jfs_check_acl(struct inode *inode, int mask) | 117 | int jfs_check_acl(struct inode *inode, int mask) |
118 | { | 118 | { |
119 | struct posix_acl *acl = jfs_get_acl(inode, ACL_TYPE_ACCESS); | 119 | struct posix_acl *acl = jfs_get_acl(inode, ACL_TYPE_ACCESS); |
120 | 120 | ||
@@ -129,11 +129,6 @@ static int jfs_check_acl(struct inode *inode, int mask) | |||
129 | return -EAGAIN; | 129 | return -EAGAIN; |
130 | } | 130 | } |
131 | 131 | ||
132 | int jfs_permission(struct inode *inode, int mask) | ||
133 | { | ||
134 | return generic_permission(inode, mask, jfs_check_acl); | ||
135 | } | ||
136 | |||
137 | int jfs_init_acl(tid_t tid, struct inode *inode, struct inode *dir) | 132 | int jfs_init_acl(tid_t tid, struct inode *inode, struct inode *dir) |
138 | { | 133 | { |
139 | struct posix_acl *acl = NULL; | 134 | struct posix_acl *acl = NULL; |
diff --git a/fs/jfs/file.c b/fs/jfs/file.c index 7f6063acaa3b..2b70fa78e4a7 100644 --- a/fs/jfs/file.c +++ b/fs/jfs/file.c | |||
@@ -96,7 +96,7 @@ const struct inode_operations jfs_file_inode_operations = { | |||
96 | .removexattr = jfs_removexattr, | 96 | .removexattr = jfs_removexattr, |
97 | #ifdef CONFIG_JFS_POSIX_ACL | 97 | #ifdef CONFIG_JFS_POSIX_ACL |
98 | .setattr = jfs_setattr, | 98 | .setattr = jfs_setattr, |
99 | .permission = jfs_permission, | 99 | .check_acl = jfs_check_acl, |
100 | #endif | 100 | #endif |
101 | }; | 101 | }; |
102 | 102 | ||
diff --git a/fs/jfs/jfs_acl.h b/fs/jfs/jfs_acl.h index 88475f10a389..b07bd417ef85 100644 --- a/fs/jfs/jfs_acl.h +++ b/fs/jfs/jfs_acl.h | |||
@@ -20,7 +20,7 @@ | |||
20 | 20 | ||
21 | #ifdef CONFIG_JFS_POSIX_ACL | 21 | #ifdef CONFIG_JFS_POSIX_ACL |
22 | 22 | ||
23 | int jfs_permission(struct inode *, int); | 23 | int jfs_check_acl(struct inode *, int); |
24 | int jfs_init_acl(tid_t, struct inode *, struct inode *); | 24 | int jfs_init_acl(tid_t, struct inode *, struct inode *); |
25 | int jfs_setattr(struct dentry *, struct iattr *); | 25 | int jfs_setattr(struct dentry *, struct iattr *); |
26 | 26 | ||
diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c index 514ee2edb92a..c79a4270f083 100644 --- a/fs/jfs/namei.c +++ b/fs/jfs/namei.c | |||
@@ -1543,7 +1543,7 @@ const struct inode_operations jfs_dir_inode_operations = { | |||
1543 | .removexattr = jfs_removexattr, | 1543 | .removexattr = jfs_removexattr, |
1544 | #ifdef CONFIG_JFS_POSIX_ACL | 1544 | #ifdef CONFIG_JFS_POSIX_ACL |
1545 | .setattr = jfs_setattr, | 1545 | .setattr = jfs_setattr, |
1546 | .permission = jfs_permission, | 1546 | .check_acl = jfs_check_acl, |
1547 | #endif | 1547 | #endif |
1548 | }; | 1548 | }; |
1549 | 1549 | ||
diff --git a/fs/namei.c b/fs/namei.c index 1f13751693a5..ed27bb205b7e 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
@@ -169,19 +169,10 @@ void putname(const char *name) | |||
169 | EXPORT_SYMBOL(putname); | 169 | EXPORT_SYMBOL(putname); |
170 | #endif | 170 | #endif |
171 | 171 | ||
172 | 172 | /* | |
173 | /** | 173 | * This does basic POSIX ACL permission checking |
174 | * generic_permission - check for access rights on a Posix-like filesystem | ||
175 | * @inode: inode to check access rights for | ||
176 | * @mask: right to check for (%MAY_READ, %MAY_WRITE, %MAY_EXEC) | ||
177 | * @check_acl: optional callback to check for Posix ACLs | ||
178 | * | ||
179 | * Used to check for read/write/execute permissions on a file. | ||
180 | * We use "fsuid" for this, letting us set arbitrary permissions | ||
181 | * for filesystem access without changing the "normal" uids which | ||
182 | * are used for other things.. | ||
183 | */ | 174 | */ |
184 | int generic_permission(struct inode *inode, int mask, | 175 | static int acl_permission_check(struct inode *inode, int mask, |
185 | int (*check_acl)(struct inode *inode, int mask)) | 176 | int (*check_acl)(struct inode *inode, int mask)) |
186 | { | 177 | { |
187 | umode_t mode = inode->i_mode; | 178 | umode_t mode = inode->i_mode; |
@@ -193,9 +184,7 @@ int generic_permission(struct inode *inode, int mask, | |||
193 | else { | 184 | else { |
194 | if (IS_POSIXACL(inode) && (mode & S_IRWXG) && check_acl) { | 185 | if (IS_POSIXACL(inode) && (mode & S_IRWXG) && check_acl) { |
195 | int error = check_acl(inode, mask); | 186 | int error = check_acl(inode, mask); |
196 | if (error == -EACCES) | 187 | if (error != -EAGAIN) |
197 | goto check_capabilities; | ||
198 | else if (error != -EAGAIN) | ||
199 | return error; | 188 | return error; |
200 | } | 189 | } |
201 | 190 | ||
@@ -208,8 +197,32 @@ int generic_permission(struct inode *inode, int mask, | |||
208 | */ | 197 | */ |
209 | if ((mask & ~mode) == 0) | 198 | if ((mask & ~mode) == 0) |
210 | return 0; | 199 | return 0; |
200 | return -EACCES; | ||
201 | } | ||
202 | |||
203 | /** | ||
204 | * generic_permission - check for access rights on a Posix-like filesystem | ||
205 | * @inode: inode to check access rights for | ||
206 | * @mask: right to check for (%MAY_READ, %MAY_WRITE, %MAY_EXEC) | ||
207 | * @check_acl: optional callback to check for Posix ACLs | ||
208 | * | ||
209 | * Used to check for read/write/execute permissions on a file. | ||
210 | * We use "fsuid" for this, letting us set arbitrary permissions | ||
211 | * for filesystem access without changing the "normal" uids which | ||
212 | * are used for other things.. | ||
213 | */ | ||
214 | int generic_permission(struct inode *inode, int mask, | ||
215 | int (*check_acl)(struct inode *inode, int mask)) | ||
216 | { | ||
217 | int ret; | ||
218 | |||
219 | /* | ||
220 | * Do the basic POSIX ACL permission checks. | ||
221 | */ | ||
222 | ret = acl_permission_check(inode, mask, check_acl); | ||
223 | if (ret != -EACCES) | ||
224 | return ret; | ||
211 | 225 | ||
212 | check_capabilities: | ||
213 | /* | 226 | /* |
214 | * Read/write DACs are always overridable. | 227 | * Read/write DACs are always overridable. |
215 | * Executable DACs are overridable if at least one exec bit is set. | 228 | * Executable DACs are overridable if at least one exec bit is set. |
@@ -262,7 +275,7 @@ int inode_permission(struct inode *inode, int mask) | |||
262 | if (inode->i_op->permission) | 275 | if (inode->i_op->permission) |
263 | retval = inode->i_op->permission(inode, mask); | 276 | retval = inode->i_op->permission(inode, mask); |
264 | else | 277 | else |
265 | retval = generic_permission(inode, mask, NULL); | 278 | retval = generic_permission(inode, mask, inode->i_op->check_acl); |
266 | 279 | ||
267 | if (retval) | 280 | if (retval) |
268 | return retval; | 281 | return retval; |
@@ -432,29 +445,22 @@ static struct dentry * cached_lookup(struct dentry * parent, struct qstr * name, | |||
432 | */ | 445 | */ |
433 | static int exec_permission_lite(struct inode *inode) | 446 | static int exec_permission_lite(struct inode *inode) |
434 | { | 447 | { |
435 | umode_t mode = inode->i_mode; | 448 | int ret; |
436 | |||
437 | if (inode->i_op->permission) | ||
438 | return -EAGAIN; | ||
439 | |||
440 | if (current_fsuid() == inode->i_uid) | ||
441 | mode >>= 6; | ||
442 | else if (in_group_p(inode->i_gid)) | ||
443 | mode >>= 3; | ||
444 | |||
445 | if (mode & MAY_EXEC) | ||
446 | goto ok; | ||
447 | 449 | ||
448 | if ((inode->i_mode & S_IXUGO) && capable(CAP_DAC_OVERRIDE)) | 450 | if (inode->i_op->permission) { |
449 | goto ok; | 451 | ret = inode->i_op->permission(inode, MAY_EXEC); |
450 | 452 | if (!ret) | |
451 | if (S_ISDIR(inode->i_mode) && capable(CAP_DAC_OVERRIDE)) | 453 | goto ok; |
454 | return ret; | ||
455 | } | ||
456 | ret = acl_permission_check(inode, MAY_EXEC, inode->i_op->check_acl); | ||
457 | if (!ret) | ||
452 | goto ok; | 458 | goto ok; |
453 | 459 | ||
454 | if (S_ISDIR(inode->i_mode) && capable(CAP_DAC_READ_SEARCH)) | 460 | if (capable(CAP_DAC_OVERRIDE) || capable(CAP_DAC_READ_SEARCH)) |
455 | goto ok; | 461 | goto ok; |
456 | 462 | ||
457 | return -EACCES; | 463 | return ret; |
458 | ok: | 464 | ok: |
459 | return security_inode_permission(inode, MAY_EXEC); | 465 | return security_inode_permission(inode, MAY_EXEC); |
460 | } | 466 | } |
@@ -853,12 +859,6 @@ static int __link_path_walk(const char *name, struct nameidata *nd) | |||
853 | 859 | ||
854 | nd->flags |= LOOKUP_CONTINUE; | 860 | nd->flags |= LOOKUP_CONTINUE; |
855 | err = exec_permission_lite(inode); | 861 | err = exec_permission_lite(inode); |
856 | if (err == -EAGAIN) | ||
857 | err = inode_permission(nd->path.dentry->d_inode, | ||
858 | MAY_EXEC); | ||
859 | if (!err) | ||
860 | err = ima_path_check(&nd->path, MAY_EXEC, | ||
861 | IMA_COUNT_UPDATE); | ||
862 | if (err) | 862 | if (err) |
863 | break; | 863 | break; |
864 | 864 | ||
diff --git a/fs/xfs/linux-2.6/xfs_iops.c b/fs/xfs/linux-2.6/xfs_iops.c index 8070b34cc287..6c32f1d63d8c 100644 --- a/fs/xfs/linux-2.6/xfs_iops.c +++ b/fs/xfs/linux-2.6/xfs_iops.c | |||
@@ -485,14 +485,6 @@ xfs_vn_put_link( | |||
485 | } | 485 | } |
486 | 486 | ||
487 | STATIC int | 487 | STATIC int |
488 | xfs_vn_permission( | ||
489 | struct inode *inode, | ||
490 | int mask) | ||
491 | { | ||
492 | return generic_permission(inode, mask, xfs_check_acl); | ||
493 | } | ||
494 | |||
495 | STATIC int | ||
496 | xfs_vn_getattr( | 488 | xfs_vn_getattr( |
497 | struct vfsmount *mnt, | 489 | struct vfsmount *mnt, |
498 | struct dentry *dentry, | 490 | struct dentry *dentry, |
@@ -696,7 +688,7 @@ xfs_vn_fiemap( | |||
696 | } | 688 | } |
697 | 689 | ||
698 | static const struct inode_operations xfs_inode_operations = { | 690 | static const struct inode_operations xfs_inode_operations = { |
699 | .permission = xfs_vn_permission, | 691 | .check_acl = xfs_check_acl, |
700 | .truncate = xfs_vn_truncate, | 692 | .truncate = xfs_vn_truncate, |
701 | .getattr = xfs_vn_getattr, | 693 | .getattr = xfs_vn_getattr, |
702 | .setattr = xfs_vn_setattr, | 694 | .setattr = xfs_vn_setattr, |
@@ -724,7 +716,7 @@ static const struct inode_operations xfs_dir_inode_operations = { | |||
724 | .rmdir = xfs_vn_unlink, | 716 | .rmdir = xfs_vn_unlink, |
725 | .mknod = xfs_vn_mknod, | 717 | .mknod = xfs_vn_mknod, |
726 | .rename = xfs_vn_rename, | 718 | .rename = xfs_vn_rename, |
727 | .permission = xfs_vn_permission, | 719 | .check_acl = xfs_check_acl, |
728 | .getattr = xfs_vn_getattr, | 720 | .getattr = xfs_vn_getattr, |
729 | .setattr = xfs_vn_setattr, | 721 | .setattr = xfs_vn_setattr, |
730 | .setxattr = generic_setxattr, | 722 | .setxattr = generic_setxattr, |
@@ -749,7 +741,7 @@ static const struct inode_operations xfs_dir_ci_inode_operations = { | |||
749 | .rmdir = xfs_vn_unlink, | 741 | .rmdir = xfs_vn_unlink, |
750 | .mknod = xfs_vn_mknod, | 742 | .mknod = xfs_vn_mknod, |
751 | .rename = xfs_vn_rename, | 743 | .rename = xfs_vn_rename, |
752 | .permission = xfs_vn_permission, | 744 | .check_acl = xfs_check_acl, |
753 | .getattr = xfs_vn_getattr, | 745 | .getattr = xfs_vn_getattr, |
754 | .setattr = xfs_vn_setattr, | 746 | .setattr = xfs_vn_setattr, |
755 | .setxattr = generic_setxattr, | 747 | .setxattr = generic_setxattr, |
@@ -762,7 +754,7 @@ static const struct inode_operations xfs_symlink_inode_operations = { | |||
762 | .readlink = generic_readlink, | 754 | .readlink = generic_readlink, |
763 | .follow_link = xfs_vn_follow_link, | 755 | .follow_link = xfs_vn_follow_link, |
764 | .put_link = xfs_vn_put_link, | 756 | .put_link = xfs_vn_put_link, |
765 | .permission = xfs_vn_permission, | 757 | .check_acl = xfs_check_acl, |
766 | .getattr = xfs_vn_getattr, | 758 | .getattr = xfs_vn_getattr, |
767 | .setattr = xfs_vn_setattr, | 759 | .setattr = xfs_vn_setattr, |
768 | .setxattr = generic_setxattr, | 760 | .setxattr = generic_setxattr, |
diff --git a/include/linux/fs.h b/include/linux/fs.h index 73e9b643e455..c1f993515f51 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -1528,6 +1528,7 @@ struct inode_operations { | |||
1528 | void (*put_link) (struct dentry *, struct nameidata *, void *); | 1528 | void (*put_link) (struct dentry *, struct nameidata *, void *); |
1529 | void (*truncate) (struct inode *); | 1529 | void (*truncate) (struct inode *); |
1530 | int (*permission) (struct inode *, int); | 1530 | int (*permission) (struct inode *, int); |
1531 | int (*check_acl)(struct inode *, int); | ||
1531 | int (*setattr) (struct dentry *, struct iattr *); | 1532 | int (*setattr) (struct dentry *, struct iattr *); |
1532 | int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *); | 1533 | int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *); |
1533 | int (*setxattr) (struct dentry *, const char *,const void *,size_t,int); | 1534 | int (*setxattr) (struct dentry *, const char *,const void *,size_t,int); |
diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h index abff6c9b413c..6d3f2f449ead 100644 --- a/include/linux/shmem_fs.h +++ b/include/linux/shmem_fs.h | |||
@@ -39,7 +39,7 @@ static inline struct shmem_inode_info *SHMEM_I(struct inode *inode) | |||
39 | } | 39 | } |
40 | 40 | ||
41 | #ifdef CONFIG_TMPFS_POSIX_ACL | 41 | #ifdef CONFIG_TMPFS_POSIX_ACL |
42 | int shmem_permission(struct inode *, int); | 42 | int shmem_check_acl(struct inode *, int); |
43 | int shmem_acl_init(struct inode *, struct inode *); | 43 | int shmem_acl_init(struct inode *, struct inode *); |
44 | 44 | ||
45 | extern struct xattr_handler shmem_xattr_acl_access_handler; | 45 | extern struct xattr_handler shmem_xattr_acl_access_handler; |
diff --git a/mm/shmem.c b/mm/shmem.c index d713239ce2ce..5a0b3d4055f3 100644 --- a/mm/shmem.c +++ b/mm/shmem.c | |||
@@ -2446,7 +2446,7 @@ static const struct inode_operations shmem_inode_operations = { | |||
2446 | .getxattr = generic_getxattr, | 2446 | .getxattr = generic_getxattr, |
2447 | .listxattr = generic_listxattr, | 2447 | .listxattr = generic_listxattr, |
2448 | .removexattr = generic_removexattr, | 2448 | .removexattr = generic_removexattr, |
2449 | .permission = shmem_permission, | 2449 | .check_acl = shmem_check_acl, |
2450 | #endif | 2450 | #endif |
2451 | 2451 | ||
2452 | }; | 2452 | }; |
@@ -2469,7 +2469,7 @@ static const struct inode_operations shmem_dir_inode_operations = { | |||
2469 | .getxattr = generic_getxattr, | 2469 | .getxattr = generic_getxattr, |
2470 | .listxattr = generic_listxattr, | 2470 | .listxattr = generic_listxattr, |
2471 | .removexattr = generic_removexattr, | 2471 | .removexattr = generic_removexattr, |
2472 | .permission = shmem_permission, | 2472 | .check_acl = shmem_check_acl, |
2473 | #endif | 2473 | #endif |
2474 | }; | 2474 | }; |
2475 | 2475 | ||
@@ -2480,7 +2480,7 @@ static const struct inode_operations shmem_special_inode_operations = { | |||
2480 | .getxattr = generic_getxattr, | 2480 | .getxattr = generic_getxattr, |
2481 | .listxattr = generic_listxattr, | 2481 | .listxattr = generic_listxattr, |
2482 | .removexattr = generic_removexattr, | 2482 | .removexattr = generic_removexattr, |
2483 | .permission = shmem_permission, | 2483 | .check_acl = shmem_check_acl, |
2484 | #endif | 2484 | #endif |
2485 | }; | 2485 | }; |
2486 | 2486 | ||
diff --git a/mm/shmem_acl.c b/mm/shmem_acl.c index 606a8e757a42..df2c87fdae50 100644 --- a/mm/shmem_acl.c +++ b/mm/shmem_acl.c | |||
@@ -157,7 +157,7 @@ shmem_acl_init(struct inode *inode, struct inode *dir) | |||
157 | /** | 157 | /** |
158 | * shmem_check_acl - check_acl() callback for generic_permission() | 158 | * shmem_check_acl - check_acl() callback for generic_permission() |
159 | */ | 159 | */ |
160 | static int | 160 | int |
161 | shmem_check_acl(struct inode *inode, int mask) | 161 | shmem_check_acl(struct inode *inode, int mask) |
162 | { | 162 | { |
163 | struct posix_acl *acl = shmem_get_acl(inode, ACL_TYPE_ACCESS); | 163 | struct posix_acl *acl = shmem_get_acl(inode, ACL_TYPE_ACCESS); |
@@ -169,12 +169,3 @@ shmem_check_acl(struct inode *inode, int mask) | |||
169 | } | 169 | } |
170 | return -EAGAIN; | 170 | return -EAGAIN; |
171 | } | 171 | } |
172 | |||
173 | /** | ||
174 | * shmem_permission - permission() inode operation | ||
175 | */ | ||
176 | int | ||
177 | shmem_permission(struct inode *inode, int mask) | ||
178 | { | ||
179 | return generic_permission(inode, mask, shmem_check_acl); | ||
180 | } | ||