aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2008-11-13 18:39:18 -0500
committerJames Morris <jmorris@namei.org>2008-11-13 18:39:18 -0500
commit86a264abe542cfececb4df129bc45a0338d8cdb9 (patch)
tree30152f04ba847f311028d5ca697f864c16c7ebb3 /fs
parentf1752eec6145c97163dbce62d17cf5d928e28a27 (diff)
CRED: Wrap current->cred and a few other accessors
Wrap current->cred and a few other accessors to hide their actual implementation. Signed-off-by: David Howells <dhowells@redhat.com> Acked-by: James Morris <jmorris@namei.org> Acked-by: Serge Hallyn <serue@us.ibm.com> Signed-off-by: James Morris <jmorris@namei.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/binfmt_elf.c10
-rw-r--r--fs/binfmt_elf_fdpic.c9
-rw-r--r--fs/exec.c5
-rw-r--r--fs/fcntl.c3
-rw-r--r--fs/file_table.c7
-rw-r--r--fs/hugetlbfs/inode.c5
-rw-r--r--fs/ioprio.c4
-rw-r--r--fs/smbfs/dir.c3
8 files changed, 24 insertions, 22 deletions
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index 7a52477ce493..0e6655613169 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -157,7 +157,7 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
157 int items; 157 int items;
158 elf_addr_t *elf_info; 158 elf_addr_t *elf_info;
159 int ei_index = 0; 159 int ei_index = 0;
160 struct task_struct *tsk = current; 160 const struct cred *cred = current_cred();
161 struct vm_area_struct *vma; 161 struct vm_area_struct *vma;
162 162
163 /* 163 /*
@@ -223,10 +223,10 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
223 NEW_AUX_ENT(AT_BASE, interp_load_addr); 223 NEW_AUX_ENT(AT_BASE, interp_load_addr);
224 NEW_AUX_ENT(AT_FLAGS, 0); 224 NEW_AUX_ENT(AT_FLAGS, 0);
225 NEW_AUX_ENT(AT_ENTRY, exec->e_entry); 225 NEW_AUX_ENT(AT_ENTRY, exec->e_entry);
226 NEW_AUX_ENT(AT_UID, tsk->cred->uid); 226 NEW_AUX_ENT(AT_UID, cred->uid);
227 NEW_AUX_ENT(AT_EUID, tsk->cred->euid); 227 NEW_AUX_ENT(AT_EUID, cred->euid);
228 NEW_AUX_ENT(AT_GID, tsk->cred->gid); 228 NEW_AUX_ENT(AT_GID, cred->gid);
229 NEW_AUX_ENT(AT_EGID, tsk->cred->egid); 229 NEW_AUX_ENT(AT_EGID, cred->egid);
230 NEW_AUX_ENT(AT_SECURE, security_bprm_secureexec(bprm)); 230 NEW_AUX_ENT(AT_SECURE, security_bprm_secureexec(bprm));
231 NEW_AUX_ENT(AT_EXECFN, bprm->exec); 231 NEW_AUX_ENT(AT_EXECFN, bprm->exec);
232 if (k_platform) { 232 if (k_platform) {
diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c
index 9f67054c2c4e..1f6e8c023b4c 100644
--- a/fs/binfmt_elf_fdpic.c
+++ b/fs/binfmt_elf_fdpic.c
@@ -475,6 +475,7 @@ static int create_elf_fdpic_tables(struct linux_binprm *bprm,
475 struct elf_fdpic_params *exec_params, 475 struct elf_fdpic_params *exec_params,
476 struct elf_fdpic_params *interp_params) 476 struct elf_fdpic_params *interp_params)
477{ 477{
478 const struct cred *cred = current_cred();
478 unsigned long sp, csp, nitems; 479 unsigned long sp, csp, nitems;
479 elf_caddr_t __user *argv, *envp; 480 elf_caddr_t __user *argv, *envp;
480 size_t platform_len = 0, len; 481 size_t platform_len = 0, len;
@@ -623,10 +624,10 @@ static int create_elf_fdpic_tables(struct linux_binprm *bprm,
623 NEW_AUX_ENT(AT_BASE, interp_params->elfhdr_addr); 624 NEW_AUX_ENT(AT_BASE, interp_params->elfhdr_addr);
624 NEW_AUX_ENT(AT_FLAGS, 0); 625 NEW_AUX_ENT(AT_FLAGS, 0);
625 NEW_AUX_ENT(AT_ENTRY, exec_params->entry_addr); 626 NEW_AUX_ENT(AT_ENTRY, exec_params->entry_addr);
626 NEW_AUX_ENT(AT_UID, (elf_addr_t) current->cred->uid); 627 NEW_AUX_ENT(AT_UID, (elf_addr_t) cred->uid);
627 NEW_AUX_ENT(AT_EUID, (elf_addr_t) current->cred->euid); 628 NEW_AUX_ENT(AT_EUID, (elf_addr_t) cred->euid);
628 NEW_AUX_ENT(AT_GID, (elf_addr_t) current->cred->gid); 629 NEW_AUX_ENT(AT_GID, (elf_addr_t) cred->gid);
629 NEW_AUX_ENT(AT_EGID, (elf_addr_t) current->cred->egid); 630 NEW_AUX_ENT(AT_EGID, (elf_addr_t) cred->egid);
630 NEW_AUX_ENT(AT_SECURE, security_bprm_secureexec(bprm)); 631 NEW_AUX_ENT(AT_SECURE, security_bprm_secureexec(bprm));
631 NEW_AUX_ENT(AT_EXECFN, bprm->exec); 632 NEW_AUX_ENT(AT_EXECFN, bprm->exec);
632 633
diff --git a/fs/exec.c b/fs/exec.c
index 31149e430a89..a5330e1a2216 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1388,6 +1388,7 @@ EXPORT_SYMBOL(set_binfmt);
1388 */ 1388 */
1389static int format_corename(char *corename, long signr) 1389static int format_corename(char *corename, long signr)
1390{ 1390{
1391 const struct cred *cred = current_cred();
1391 const char *pat_ptr = core_pattern; 1392 const char *pat_ptr = core_pattern;
1392 int ispipe = (*pat_ptr == '|'); 1393 int ispipe = (*pat_ptr == '|');
1393 char *out_ptr = corename; 1394 char *out_ptr = corename;
@@ -1424,7 +1425,7 @@ static int format_corename(char *corename, long signr)
1424 /* uid */ 1425 /* uid */
1425 case 'u': 1426 case 'u':
1426 rc = snprintf(out_ptr, out_end - out_ptr, 1427 rc = snprintf(out_ptr, out_end - out_ptr,
1427 "%d", current_uid()); 1428 "%d", cred->uid);
1428 if (rc > out_end - out_ptr) 1429 if (rc > out_end - out_ptr)
1429 goto out; 1430 goto out;
1430 out_ptr += rc; 1431 out_ptr += rc;
@@ -1432,7 +1433,7 @@ static int format_corename(char *corename, long signr)
1432 /* gid */ 1433 /* gid */
1433 case 'g': 1434 case 'g':
1434 rc = snprintf(out_ptr, out_end - out_ptr, 1435 rc = snprintf(out_ptr, out_end - out_ptr,
1435 "%d", current_gid()); 1436 "%d", cred->gid);
1436 if (rc > out_end - out_ptr) 1437 if (rc > out_end - out_ptr)
1437 goto out; 1438 goto out;
1438 out_ptr += rc; 1439 out_ptr += rc;
diff --git a/fs/fcntl.c b/fs/fcntl.c
index 63964d863ad6..c594cc0e40fb 100644
--- a/fs/fcntl.c
+++ b/fs/fcntl.c
@@ -205,13 +205,14 @@ static void f_modown(struct file *filp, struct pid *pid, enum pid_type type,
205int __f_setown(struct file *filp, struct pid *pid, enum pid_type type, 205int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
206 int force) 206 int force)
207{ 207{
208 const struct cred *cred = current_cred();
208 int err; 209 int err;
209 210
210 err = security_file_set_fowner(filp); 211 err = security_file_set_fowner(filp);
211 if (err) 212 if (err)
212 return err; 213 return err;
213 214
214 f_modown(filp, pid, type, current_uid(), current_euid(), force); 215 f_modown(filp, pid, type, cred->uid, cred->euid, force);
215 return 0; 216 return 0;
216} 217}
217EXPORT_SYMBOL(__f_setown); 218EXPORT_SYMBOL(__f_setown);
diff --git a/fs/file_table.c b/fs/file_table.c
index 3152b53cfab0..bc4563fe791d 100644
--- a/fs/file_table.c
+++ b/fs/file_table.c
@@ -94,7 +94,7 @@ int proc_nr_files(ctl_table *table, int write, struct file *filp,
94 */ 94 */
95struct file *get_empty_filp(void) 95struct file *get_empty_filp(void)
96{ 96{
97 struct task_struct *tsk; 97 const struct cred *cred = current_cred();
98 static int old_max; 98 static int old_max;
99 struct file * f; 99 struct file * f;
100 100
@@ -118,12 +118,11 @@ struct file *get_empty_filp(void)
118 if (security_file_alloc(f)) 118 if (security_file_alloc(f))
119 goto fail_sec; 119 goto fail_sec;
120 120
121 tsk = current;
122 INIT_LIST_HEAD(&f->f_u.fu_list); 121 INIT_LIST_HEAD(&f->f_u.fu_list);
123 atomic_long_set(&f->f_count, 1); 122 atomic_long_set(&f->f_count, 1);
124 rwlock_init(&f->f_owner.lock); 123 rwlock_init(&f->f_owner.lock);
125 f->f_uid = tsk->cred->fsuid; 124 f->f_uid = cred->fsuid;
126 f->f_gid = tsk->cred->fsgid; 125 f->f_gid = cred->fsgid;
127 eventpoll_init_file(f); 126 eventpoll_init_file(f);
128 /* f->f_version: 0 */ 127 /* f->f_version: 0 */
129 return f; 128 return f;
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 870a721b8bd2..7d479ce3aceb 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -951,6 +951,7 @@ struct file *hugetlb_file_setup(const char *name, size_t size)
951 struct inode *inode; 951 struct inode *inode;
952 struct dentry *dentry, *root; 952 struct dentry *dentry, *root;
953 struct qstr quick_string; 953 struct qstr quick_string;
954 struct user_struct *user = current_user();
954 955
955 if (!hugetlbfs_vfsmount) 956 if (!hugetlbfs_vfsmount)
956 return ERR_PTR(-ENOENT); 957 return ERR_PTR(-ENOENT);
@@ -958,7 +959,7 @@ struct file *hugetlb_file_setup(const char *name, size_t size)
958 if (!can_do_hugetlb_shm()) 959 if (!can_do_hugetlb_shm())
959 return ERR_PTR(-EPERM); 960 return ERR_PTR(-EPERM);
960 961
961 if (!user_shm_lock(size, current->cred->user)) 962 if (!user_shm_lock(size, user))
962 return ERR_PTR(-ENOMEM); 963 return ERR_PTR(-ENOMEM);
963 964
964 root = hugetlbfs_vfsmount->mnt_root; 965 root = hugetlbfs_vfsmount->mnt_root;
@@ -998,7 +999,7 @@ out_inode:
998out_dentry: 999out_dentry:
999 dput(dentry); 1000 dput(dentry);
1000out_shm_unlock: 1001out_shm_unlock:
1001 user_shm_unlock(size, current->cred->user); 1002 user_shm_unlock(size, user);
1002 return ERR_PTR(error); 1003 return ERR_PTR(error);
1003} 1004}
1004 1005
diff --git a/fs/ioprio.c b/fs/ioprio.c
index bb5210af77c2..5112554fd210 100644
--- a/fs/ioprio.c
+++ b/fs/ioprio.c
@@ -123,7 +123,7 @@ asmlinkage long sys_ioprio_set(int which, int who, int ioprio)
123 break; 123 break;
124 case IOPRIO_WHO_USER: 124 case IOPRIO_WHO_USER:
125 if (!who) 125 if (!who)
126 user = current->cred->user; 126 user = current_user();
127 else 127 else
128 user = find_user(who); 128 user = find_user(who);
129 129
@@ -216,7 +216,7 @@ asmlinkage long sys_ioprio_get(int which, int who)
216 break; 216 break;
217 case IOPRIO_WHO_USER: 217 case IOPRIO_WHO_USER:
218 if (!who) 218 if (!who)
219 user = current->cred->user; 219 user = current_user();
220 else 220 else
221 user = find_user(who); 221 user = find_user(who);
222 222
diff --git a/fs/smbfs/dir.c b/fs/smbfs/dir.c
index 9e9bb0db4f6d..e7ddd0328ddc 100644
--- a/fs/smbfs/dir.c
+++ b/fs/smbfs/dir.c
@@ -667,8 +667,7 @@ smb_make_node(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
667 667
668 attr.ia_valid = ATTR_MODE | ATTR_UID | ATTR_GID; 668 attr.ia_valid = ATTR_MODE | ATTR_UID | ATTR_GID;
669 attr.ia_mode = mode; 669 attr.ia_mode = mode;
670 attr.ia_uid = current_euid(); 670 current_euid_egid(&attr.ia_uid, &attr.ia_gid);
671 attr.ia_gid = current_egid();
672 671
673 if (!new_valid_dev(dev)) 672 if (!new_valid_dev(dev))
674 return -EINVAL; 673 return -EINVAL;