diff options
author | Prasanna Meda <pmeda@akamai.com> | 2004-12-02 15:46:44 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2004-12-02 15:46:44 -0800 |
commit | b545069f74abe49d141e39151b9bf15f58ef26c7 (patch) | |
tree | d4e8c0363d8f14e8007848f48c8bf3f3eeac9b8e /kernel | |
parent | d20a8fb580008dd9f81797bb0bc479f1507b5c01 (diff) | |
download | history-b545069f74abe49d141e39151b9bf15f58ef26c7.tar.gz |
[PATCH] sys_set/getpriority PRIO_USER semantics fix and optimisation
This change brings the semantics equivalent to 2.4 and also to what the man
page says; Also optimises by avoiding unneeded lookup in uid cache, when
who is same as the current->uid.
sys_set/getpriority is rewritten in 2.5/2.6, perhaps while transitioning to
the pid maps. It has now semantical bug, when uid is zero. Note that akpm
also fixed refcount leak and locking in the new functions in changeset
http://linus.bkbits.net:8080/linux-2.5/cset@1.1608.10.84
Signed-off-by: <pmeda@akamai.com>
Acked-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/sys.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/kernel/sys.c b/kernel/sys.c index d1418b30a770d9..fdc29f17ac939d 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -273,19 +273,18 @@ asmlinkage long sys_setpriority(int which, int who, int niceval) } while_each_task_pid(who, PIDTYPE_PGID, p); break; case PRIO_USER: + user = current->user; if (!who) - user = current->user; + who = current->uid; else - user = find_user(who); - - if (!user) - goto out_unlock; + if ((who != current->uid) && !(user = find_user(who))) + goto out_unlock; /* No processes for this user */ do_each_thread(g, p) if (p->uid == who) error = set_one_prio(p, niceval, error); while_each_thread(g, p); - if (who) + if (who != current->uid) free_uid(user); /* For find_user() */ break; } @@ -332,13 +331,12 @@ asmlinkage long sys_getpriority(int which, int who) } while_each_task_pid(who, PIDTYPE_PGID, p); break; case PRIO_USER: + user = current->user; if (!who) - user = current->user; + who = current->uid; else - user = find_user(who); - - if (!user) - goto out_unlock; + if ((who != current->uid) && !(user = find_user(who))) + goto out_unlock; /* No processes for this user */ do_each_thread(g, p) if (p->uid == who) { @@ -347,7 +345,7 @@ asmlinkage long sys_getpriority(int which, int who) retval = niceval; } while_each_thread(g, p); - if (who) + if (who != current->uid) free_uid(user); /* for find_user() */ break; } |