aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext3
diff options
context:
space:
mode:
authorSatyam Sharma <ssatyam@cse.iitk.ac.in>2007-07-17 05:30:08 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-17 15:00:03 -0400
commit3bd858ab1c451725c07a805dcb315215dc85b86e (patch)
tree5d49c4300e350d64fd81eb3230b81f754117e0c1 /fs/ext3
parent49c13b51a15f1ba9f6d47e26e4a3886c4f3931e2 (diff)
Introduce is_owner_or_cap() to wrap CAP_FOWNER use with fsuid check
Introduce is_owner_or_cap() macro in fs.h, and convert over relevant users to it. This is done because we want to avoid bugs in the future where we check for only effective fsuid of the current task against a file's owning uid, without simultaneously checking for CAP_FOWNER as well, thus violating its semantics. [ XFS uses special macros and structures, and in general looked ... untouchable, so we leave it alone -- but it has been looked over. ] The (current->fsuid != inode->i_uid) check in generic_permission() and exec_permission_lite() is left alone, because those operations are covered by CAP_DAC_OVERRIDE and CAP_DAC_READ_SEARCH. Similarly operations falling under the purview of CAP_CHOWN and CAP_LEASE are also left alone. Signed-off-by: Satyam Sharma <ssatyam@cse.iitk.ac.in> Cc: Al Viro <viro@ftp.linux.org.uk> Acked-by: Serge E. Hallyn <serge@hallyn.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/ext3')
-rw-r--r--fs/ext3/acl.c2
-rw-r--r--fs/ext3/ioctl.c6
2 files changed, 4 insertions, 4 deletions
diff --git a/fs/ext3/acl.c b/fs/ext3/acl.c
index 1e5038d9a01b..d34e9967430a 100644
--- a/fs/ext3/acl.c
+++ b/fs/ext3/acl.c
@@ -489,7 +489,7 @@ ext3_xattr_set_acl(struct inode *inode, int type, const void *value,
489 489
490 if (!test_opt(inode->i_sb, POSIX_ACL)) 490 if (!test_opt(inode->i_sb, POSIX_ACL))
491 return -EOPNOTSUPP; 491 return -EOPNOTSUPP;
492 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER)) 492 if (!is_owner_or_cap(inode))
493 return -EPERM; 493 return -EPERM;
494 494
495 if (value) { 495 if (value) {
diff --git a/fs/ext3/ioctl.c b/fs/ext3/ioctl.c
index 965006dba6be..4a2a02c95bf9 100644
--- a/fs/ext3/ioctl.c
+++ b/fs/ext3/ioctl.c
@@ -41,7 +41,7 @@ int ext3_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
41 if (IS_RDONLY(inode)) 41 if (IS_RDONLY(inode))
42 return -EROFS; 42 return -EROFS;
43 43
44 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER)) 44 if (!is_owner_or_cap(inode))
45 return -EACCES; 45 return -EACCES;
46 46
47 if (get_user(flags, (int __user *) arg)) 47 if (get_user(flags, (int __user *) arg))
@@ -122,7 +122,7 @@ flags_err:
122 __u32 generation; 122 __u32 generation;
123 int err; 123 int err;
124 124
125 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER)) 125 if (!is_owner_or_cap(inode))
126 return -EPERM; 126 return -EPERM;
127 if (IS_RDONLY(inode)) 127 if (IS_RDONLY(inode))
128 return -EROFS; 128 return -EROFS;
@@ -181,7 +181,7 @@ flags_err:
181 if (IS_RDONLY(inode)) 181 if (IS_RDONLY(inode))
182 return -EROFS; 182 return -EROFS;
183 183
184 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER)) 184 if (!is_owner_or_cap(inode))
185 return -EACCES; 185 return -EACCES;
186 186
187 if (get_user(rsv_window_size, (int __user *)arg)) 187 if (get_user(rsv_window_size, (int __user *)arg))