Commit 76d523bc authored by Stéphane Eranian's avatar Stéphane Eranian Committed by David Mosberger

[PATCH] ia64: perfmon2 update

This patch fixes the following:

        - correct a bug in pfm_close() which was causing some per-process 
          sessions to not unreserve on exit.

        - changed the permission checking to load a context to allow more
          flexibility, modeled after ptrace_attach().
parent 9acd4172
......@@ -1975,8 +1975,6 @@ pfm_close(struct inode *inode, struct file *filp)
PROTECT_CTX(ctx, flags);
/* reload state, may have changed during opening of critical section */
state = ctx->ctx_state;
remove_wait_queue(&ctx->ctx_zombieq, &wait);
set_current_state(TASK_RUNNING);
......@@ -2005,6 +2003,10 @@ pfm_close(struct inode *inode, struct file *filp)
}
doit: /* cannot assume task is defined from now on */
/* reload state, may have changed during opening of critical section */
state = ctx->ctx_state;
/*
* the context is still attached to a task (possibly current)
* we cannot destroy it right now
......@@ -2037,7 +2039,7 @@ pfm_close(struct inode *inode, struct file *filp)
DPRINT(("[%d] ctx_state=%d free_possible=%d vaddr=%p addr=%p size=%lu\n",
current->pid,
ctx->ctx_state,
state,
free_possible,
smpl_buf_vaddr,
smpl_buf_addr,
......@@ -2362,10 +2364,23 @@ pfm_smpl_buffer_alloc(struct task_struct *task, pfm_context_t *ctx, unsigned lon
static int
pfm_bad_permissions(struct task_struct *task)
{
/* stolen from bad_signal() */
return (current->session != task->session)
&& (current->euid ^ task->suid) && (current->euid ^ task->uid)
&& (current->uid ^ task->suid) && (current->uid ^ task->uid);
/* inspired by ptrace_attach() */
DPRINT(("[%d] cur: uid=%d gid=%d task: euid=%d suid=%d uid=%d egid=%d sgid=%d\n",
current->pid,
current->uid,
current->gid,
task->euid,
task->suid,
task->uid,
task->egid,
task->sgid));
return ((current->uid != task->euid)
|| (current->uid != task->suid)
|| (current->uid != task->uid)
|| (current->gid != task->egid)
|| (current->gid != task->sgid)
|| (current->gid != task->gid)) && !capable(CAP_SYS_PTRACE);
}
static int
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment