summaryrefslogtreecommitdiff
path: root/mm
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2008-08-07 20:02:12 +1000
committerJames Morris <jmorris@namei.org>2008-08-07 20:02:12 +1000
commitf4d399d40debd14b22967153294b94087cbcf789 (patch)
tree74adf7e935d48d2c90d3a9fdcee33169a230111d /mm
parent785af0f385cd424d4b40908bf0e467df3dc05434 (diff)
CRED: Wrap most current->e?[ug]id and some task->e?[ug]id
Change most current->e?[ug]id to current_e?[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 are addressed by a later patch (see the patch entitled "CRED: Use RCU to access another task's creds and to release a task's own creds"). Signed-off-by: David Howells <dhowells@redhat.com> Reviewed-by: James Morris <jmorris@namei.org> Acked-by: Serge Hallyn <serue@us.ibm.com>
Diffstat (limited to 'mm')
-rw-r--r--mm/mempolicy.c7
-rw-r--r--mm/migrate.c7
2 files changed, 10 insertions, 4 deletions
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index e550bec20582..64194978382d 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -1111,6 +1111,7 @@ asmlinkage long sys_migrate_pages(pid_t pid, unsigned long maxnode,
nodemask_t old;
nodemask_t new;
nodemask_t task_nodes;
+ uid_t uid, euid;
int err;
err = get_nodes(&old, old_nodes, maxnode);
@@ -1140,8 +1141,10 @@ asmlinkage long sys_migrate_pages(pid_t pid, unsigned long maxnode,
* capabilities, superuser privileges or the same
* userid as the target process.
*/
- if ((current->euid != task->suid) && (current->euid != task->uid) &&
- (current->uid != task->suid) && (current->uid != task->uid) &&
+ uid = current_uid();
+ euid = current_euid();
+ if (euid != task->suid && euid != task->uid &&
+ uid != task->suid && uid != task->uid &&
!capable(CAP_SYS_NICE)) {
err = -EPERM;
goto out;
diff --git a/mm/migrate.c b/mm/migrate.c
index 153572fb60b8..efc200b68fb5 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -990,6 +990,7 @@ asmlinkage long sys_move_pages(pid_t pid, unsigned long nr_pages,
nodemask_t task_nodes;
struct mm_struct *mm;
struct page_to_node *pm = NULL;
+ uid_t uid, euid;
/* Check flags */
if (flags & ~(MPOL_MF_MOVE|MPOL_MF_MOVE_ALL))
@@ -1017,8 +1018,10 @@ asmlinkage long sys_move_pages(pid_t pid, unsigned long nr_pages,
* capabilities, superuser privileges or the same
* userid as the target process.
*/
- if ((current->euid != task->suid) && (current->euid != task->uid) &&
- (current->uid != task->suid) && (current->uid != task->uid) &&
+ uid = current_uid();
+ euid = current_euid();
+ if (euid != task->suid && euid != task->uid &&
+ uid != task->suid && uid != task->uid &&
!capable(CAP_SYS_NICE)) {
err = -EPERM;
goto out2;