aboutsummaryrefslogtreecommitdiffstats
path: root/fs/namei.c
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2008-11-13 18:39:05 -0500
committerJames Morris <jmorris@namei.org>2008-11-13 18:39:05 -0500
commitda9592edebceeba1b9301beafe80ec8b9c2db0ce (patch)
tree00c110cd8ff6d211d76ab4868b6175096a38aad5 /fs/namei.c
parent82ab8deda7fef36f067ccdeacc3b3caefc970f89 (diff)
CRED: Wrap task credential accesses in the filesystem subsystem
Wrap access to task credentials so that they can be separated more easily from the task_struct during the introduction of COW creds. Change most current->(|e|s|fs)[ug]id to current_(|e|s|fs)[ug]id(). Change some task->e?[ug]id to task_e?[ug]id(). In some places it makes more sense to use RCU directly rather than a convenient wrapper; these will be addressed by later patches. Signed-off-by: David Howells <dhowells@redhat.com> Reviewed-by: James Morris <jmorris@namei.org> Acked-by: Serge Hallyn <serue@us.ibm.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: James Morris <jmorris@namei.org>
Diffstat (limited to 'fs/namei.c')
-rw-r--r--fs/namei.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/fs/namei.c b/fs/namei.c
index 09ce58e49e72..42d7b7606936 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -186,7 +186,7 @@ int generic_permission(struct inode *inode, int mask,
186 186
187 mask &= MAY_READ | MAY_WRITE | MAY_EXEC; 187 mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
188 188
189 if (current->fsuid == inode->i_uid) 189 if (current_fsuid() == inode->i_uid)
190 mode >>= 6; 190 mode >>= 6;
191 else { 191 else {
192 if (IS_POSIXACL(inode) && (mode & S_IRWXG) && check_acl) { 192 if (IS_POSIXACL(inode) && (mode & S_IRWXG) && check_acl) {
@@ -441,7 +441,7 @@ static int exec_permission_lite(struct inode *inode)
441 if (inode->i_op && inode->i_op->permission) 441 if (inode->i_op && inode->i_op->permission)
442 return -EAGAIN; 442 return -EAGAIN;
443 443
444 if (current->fsuid == inode->i_uid) 444 if (current_fsuid() == inode->i_uid)
445 mode >>= 6; 445 mode >>= 6;
446 else if (in_group_p(inode->i_gid)) 446 else if (in_group_p(inode->i_gid))
447 mode >>= 3; 447 mode >>= 3;
@@ -1334,11 +1334,13 @@ static int user_path_parent(int dfd, const char __user *path,
1334 */ 1334 */
1335static inline int check_sticky(struct inode *dir, struct inode *inode) 1335static inline int check_sticky(struct inode *dir, struct inode *inode)
1336{ 1336{
1337 uid_t fsuid = current_fsuid();
1338
1337 if (!(dir->i_mode & S_ISVTX)) 1339 if (!(dir->i_mode & S_ISVTX))
1338 return 0; 1340 return 0;
1339 if (inode->i_uid == current->fsuid) 1341 if (inode->i_uid == fsuid)
1340 return 0; 1342 return 0;
1341 if (dir->i_uid == current->fsuid) 1343 if (dir->i_uid == fsuid)
1342 return 0; 1344 return 0;
1343 return !capable(CAP_FOWNER); 1345 return !capable(CAP_FOWNER);
1344} 1346}