diff options
author | Ingo Molnar <mingo@elte.hu> | 2009-03-04 11:42:31 +0100 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-03-04 11:42:31 +0100 |
commit | 8163d88c79dca35478a2405c837733ac50ea4c39 (patch) | |
tree | 6acae066a09b7dcbedab4a35ad62eba4ba3fd83c /kernel/sys.c | |
parent | a1ef58f442542d8b3e3b963339fbc522c36e827c (diff) | |
parent | fec6c6fec3e20637bee5d276fb61dd8b49a3f9cc (diff) | |
download | linux-8163d88c79dca35478a2405c837733ac50ea4c39.tar.gz linux-8163d88c79dca35478a2405c837733ac50ea4c39.tar.bz2 linux-8163d88c79dca35478a2405c837733ac50ea4c39.zip |
Merge commit 'v2.6.29-rc7' into perfcounters/core
Conflicts:
arch/x86/mm/iomap_32.c
Diffstat (limited to 'kernel/sys.c')
-rw-r--r-- | kernel/sys.c | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/kernel/sys.c b/kernel/sys.c index c5e7dec4966e..7306f9421aac 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -560,7 +560,7 @@ error: abort_creds(new); return retval; } - + /* * change the user struct in a credentials set to match the new UID */ @@ -572,6 +572,11 @@ static int set_user(struct cred *new) if (!new_user) return -EAGAIN; + if (!task_can_switch_user(new_user, current)) { + free_uid(new_user); + return -EINVAL; + } + if (atomic_read(&new_user->processes) >= current->signal->rlim[RLIMIT_NPROC].rlim_cur && new_user != INIT_USER) { @@ -632,10 +637,11 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid) goto error; } - retval = -EAGAIN; - if (new->uid != old->uid && set_user(new) < 0) - goto error; - + if (new->uid != old->uid) { + retval = set_user(new); + if (retval < 0) + goto error; + } if (ruid != (uid_t) -1 || (euid != (uid_t) -1 && euid != old->uid)) new->suid = new->euid; @@ -681,9 +687,10 @@ SYSCALL_DEFINE1(setuid, uid_t, uid) retval = -EPERM; if (capable(CAP_SETUID)) { new->suid = new->uid = uid; - if (uid != old->uid && set_user(new) < 0) { - retval = -EAGAIN; - goto error; + if (uid != old->uid) { + retval = set_user(new); + if (retval < 0) + goto error; } } else if (uid != old->uid && uid != new->suid) { goto error; @@ -735,11 +742,13 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid) goto error; } - retval = -EAGAIN; if (ruid != (uid_t) -1) { new->uid = ruid; - if (ruid != old->uid && set_user(new) < 0) - goto error; + if (ruid != old->uid) { + retval = set_user(new); + if (retval < 0) + goto error; + } } if (euid != (uid_t) -1) new->euid = euid; |