Commit f5110cae authored by David Mosberger's avatar David Mosberger

ia64: Patch by Andreas Schwab to fix sys32_ptrace().

parent f3b19a5c
...@@ -2852,26 +2852,23 @@ sys32_ptrace (int request, pid_t pid, unsigned int addr, unsigned int data, ...@@ -2852,26 +2852,23 @@ sys32_ptrace (int request, pid_t pid, unsigned int addr, unsigned int data,
ret = -ESRCH; ret = -ESRCH;
read_lock(&tasklist_lock); read_lock(&tasklist_lock);
child = find_task_by_pid(pid); child = find_task_by_pid(pid);
if (child)
get_task_struct(child);
read_unlock(&tasklist_lock); read_unlock(&tasklist_lock);
if (!child) if (!child)
goto out; goto out;
ret = -EPERM; ret = -EPERM;
if (pid == 1) /* no messing around with init! */ if (pid == 1) /* no messing around with init! */
goto out; goto out_tsk;
if (request == PTRACE_ATTACH) { if (request == PTRACE_ATTACH) {
ret = sys_ptrace(request, pid, addr, data, arg4, arg5, arg6, arg7, stack); ret = sys_ptrace(request, pid, addr, data, arg4, arg5, arg6, arg7, stack);
goto out; goto out_tsk;
}
ret = -ESRCH;
if (!(child->ptrace & PT_PTRACED))
goto out;
if (child->state != TASK_STOPPED) {
if (request != PTRACE_KILL)
goto out;
} }
if (child->parent != current)
goto out; ret = ptrace_check_attach(child, request == PTRACE_KILL);
if (ret < 0)
goto out_tsk;
switch (request) { switch (request) {
case PTRACE_PEEKTEXT: case PTRACE_PEEKTEXT:
...@@ -2881,12 +2878,12 @@ sys32_ptrace (int request, pid_t pid, unsigned int addr, unsigned int data, ...@@ -2881,12 +2878,12 @@ sys32_ptrace (int request, pid_t pid, unsigned int addr, unsigned int data,
ret = put_user(value, (unsigned int *) A(data)); ret = put_user(value, (unsigned int *) A(data));
else else
ret = -EIO; ret = -EIO;
goto out; goto out_tsk;
case PTRACE_POKETEXT: case PTRACE_POKETEXT:
case PTRACE_POKEDATA: /* write the word at location addr */ case PTRACE_POKEDATA: /* write the word at location addr */
ret = ia32_poke(regs, child, addr, data); ret = ia32_poke(regs, child, addr, data);
goto out; goto out_tsk;
case PTRACE_PEEKUSR: /* read word at addr in USER area */ case PTRACE_PEEKUSR: /* read word at addr in USER area */
ret = -EIO; ret = -EIO;
...@@ -2961,6 +2958,8 @@ sys32_ptrace (int request, pid_t pid, unsigned int addr, unsigned int data, ...@@ -2961,6 +2958,8 @@ sys32_ptrace (int request, pid_t pid, unsigned int addr, unsigned int data,
break; break;
} }
out_tsk:
free_task_struct(child);
out: out:
unlock_kernel(); unlock_kernel();
return ret; return ret;
......
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