Fix error checking in sys32_ptrace
This fixes sys32_ptrace to use ptrace_check_attach, so that it automatically inherits all future enhancements there.
Andreas.
arch/ia64/ia32/sys_ia32.c renamed from arch/ia64/ia32/sys_ia32.c.~1~ +12 -13
@@ -3076,26 +3076,23 @@ sys32_ptrace (int request, pid_t pid, un ret = -ESRCH ;read_lock (&tasklist_lock); child =find_task_by_pid (pid); +if (child) +get_task_struct (child);read_unlock (&tasklist_lock);if (!child) goto out; ret = -EPERM ;if (pid =1 )/* no messing around with init! */ - goto out; + goto out_tsk;if (request =PTRACE_ATTACH ) { ret =sys_ptrace (request, pid, addr, data, arg4, arg5, arg6, arg7, stack); - goto out; - } - ret = -ESRCH ; -if (!(child->ptrace &PT_PTRACED )) - goto out; -if (child->state !=TASK_STOPPED ) { -if (request !=PTRACE_KILL ) - goto out; + goto out_tsk; } -if (child->p_pptr != current) - goto out; + + ret =ptrace_check_attach (child, request =PTRACE_KILL ); +if (ret <0 ) + goto out_tsk;switch (request) {case PTRACE_PEEKTEXT :
@@ -3105,12 +3102,12 @@ sys32_ptrace (int request, pid_t pid, un ret =put_user (value, (unsigned int *)A (data)); else ret = -EIO ; - goto out; + goto out_tsk;case PTRACE_POKETEXT :case PTRACE_POKEDATA :/* write the word at location addr */ ret =ia32_poke (regs, child, addr, data); - goto out; + goto out_tsk;case PTRACE_PEEKUSR :/* read word at addr in USER area */ ret = -EIO ;
@@ -3185,6 +3182,8 @@ sys32_ptrace (int request, pid_t pid, unbreak ; } + out_tsk: +free_task_struct (child); out:unlock_kernel ();return ret;
Signature · 4 lines
Andreas Schwab, SuSE Labs, [email protected] SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nürnberg Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Andreas Schwab
Andreas> This fixes sys32_ptrace to use ptrace_check_attach, so that it Andreas> automatically inherits all future enhancements there.
The patch didn't apply in 2.5, but I merged it manually.
Thanks,
--david
Quoted 2 lines · Andreas Schwab
This fixes
sys32_ptraceto useptrace_check_attach, so that it automatically inherits all future enhancements there.
I applied this in 2.4.