diff options
author | David Howells <dhowells@redhat.com> | 2008-11-13 18:39:19 -0500 |
---|---|---|
committer | James Morris <jmorris@namei.org> | 2008-11-13 18:39:19 -0500 |
commit | c69e8d9c01db2adc503464993c358901c9af9de4 (patch) | |
tree | bed94aaa9aeb7a7834d1c880f72b62a11a752c78 /arch/ia64 | |
parent | 86a264abe542cfececb4df129bc45a0338d8cdb9 (diff) |
CRED: Use RCU to access another task's creds and to release a task's own creds
Use RCU to access another task's creds and to release a task's own creds.
This means that it will be possible for the credentials of a task to be
replaced without another task (a) requiring a full lock to read them, and (b)
seeing deallocated memory.
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 'arch/ia64')
-rw-r--r-- | arch/ia64/kernel/perfmon.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c index dd38db46a77a..0e499757309b 100644 --- a/arch/ia64/kernel/perfmon.c +++ b/arch/ia64/kernel/perfmon.c | |||
@@ -2399,25 +2399,33 @@ error_kmem: | |||
2399 | static int | 2399 | static int |
2400 | pfm_bad_permissions(struct task_struct *task) | 2400 | pfm_bad_permissions(struct task_struct *task) |
2401 | { | 2401 | { |
2402 | const struct cred *tcred; | ||
2402 | uid_t uid = current_uid(); | 2403 | uid_t uid = current_uid(); |
2403 | gid_t gid = current_gid(); | 2404 | gid_t gid = current_gid(); |
2405 | int ret; | ||
2406 | |||
2407 | rcu_read_lock(); | ||
2408 | tcred = __task_cred(task); | ||
2404 | 2409 | ||
2405 | /* inspired by ptrace_attach() */ | 2410 | /* inspired by ptrace_attach() */ |
2406 | DPRINT(("cur: uid=%d gid=%d task: euid=%d suid=%d uid=%d egid=%d sgid=%d\n", | 2411 | DPRINT(("cur: uid=%d gid=%d task: euid=%d suid=%d uid=%d egid=%d sgid=%d\n", |
2407 | uid, | 2412 | uid, |
2408 | gid, | 2413 | gid, |
2409 | task->euid, | 2414 | tcred->euid, |
2410 | task->suid, | 2415 | tcred->suid, |
2411 | task->uid, | 2416 | tcred->uid, |
2412 | task->egid, | 2417 | tcred->egid, |
2413 | task->sgid)); | 2418 | tcred->sgid)); |
2414 | 2419 | ||
2415 | return (uid != task->euid) | 2420 | ret = ((uid != tcred->euid) |
2416 | || (uid != task->suid) | 2421 | || (uid != tcred->suid) |
2417 | || (uid != task->uid) | 2422 | || (uid != tcred->uid) |
2418 | || (gid != task->egid) | 2423 | || (gid != tcred->egid) |
2419 | || (gid != task->sgid) | 2424 | || (gid != tcred->sgid) |
2420 | || (gid != task->gid)) && !capable(CAP_SYS_PTRACE); | 2425 | || (gid != tcred->gid)) && !capable(CAP_SYS_PTRACE); |
2426 | |||
2427 | rcu_read_unlock(); | ||
2428 | return ret; | ||
2421 | } | 2429 | } |
2422 | 2430 | ||
2423 | static int | 2431 | static int |