Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

alpha: use generic ptrace_resume code

Use the generic ptrace_resume code for PTRACE_SYSCALL, PTRACE_CONT,
PTRACE_KILL and PTRACE_SINGLESTEP. This implies defining
arch_has_single_step in <asm/ptrace.h> and implementing the
user_enable_single_step and user_disable_single_step functions, which also
causes the breakpoint information to be cleared on fork, which could be
considered a bug fix.

Also the TIF_SYSCALL_TRACE thread flag is now cleared on PTRACE_KILL which
it previously wasn't, which is consistent with all architectures using the
modern ptrace code.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Roland McGrath <roland@redhat.com>
Acked-by: Matt Turner <mattst88@gmail.com>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Richard Henderson <rth@twiddle.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Christoph Hellwig and committed by
Linus Torvalds
fd341abb dacbe41f

+13 -47
+1
arch/alpha/include/asm/ptrace.h
··· 68 68 69 69 #ifdef __KERNEL__ 70 70 71 + #define arch_has_single_step() (1) 71 72 #define user_mode(regs) (((regs)->ps & 8) != 0) 72 73 #define instruction_pointer(regs) ((regs)->pc) 73 74 #define profile_pc(regs) instruction_pointer(regs)
+12 -47
arch/alpha/kernel/ptrace.c
··· 249 249 return (nsaved != 0); 250 250 } 251 251 252 + void user_enable_single_step(struct task_struct *child) 253 + { 254 + /* Mark single stepping. */ 255 + task_thread_info(child)->bpt_nsaved = -1; 256 + } 257 + 258 + void user_disable_single_step(struct task_struct *child) 259 + { 260 + ptrace_cancel_bpt(child); 261 + } 262 + 252 263 /* 253 264 * Called by kernel/ptrace.c when detaching.. 254 265 * ··· 267 256 */ 268 257 void ptrace_disable(struct task_struct *child) 269 258 { 270 - ptrace_cancel_bpt(child); 259 + user_disable_single_step(child); 271 260 } 272 261 273 262 long arch_ptrace(struct task_struct *child, long request, long addr, long data) ··· 306 295 DBG(DBG_MEM, ("poke $%ld<-%#lx\n", addr, data)); 307 296 ret = put_reg(child, addr, data); 308 297 break; 309 - 310 - case PTRACE_SYSCALL: 311 - /* continue and stop at next (return from) syscall */ 312 - case PTRACE_CONT: /* restart after signal. */ 313 - ret = -EIO; 314 - if (!valid_signal(data)) 315 - break; 316 - if (request == PTRACE_SYSCALL) 317 - set_tsk_thread_flag(child, TIF_SYSCALL_TRACE); 318 - else 319 - clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); 320 - child->exit_code = data; 321 - /* make sure single-step breakpoint is gone. */ 322 - ptrace_cancel_bpt(child); 323 - wake_up_process(child); 324 - ret = 0; 325 - break; 326 - 327 - /* 328 - * Make the child exit. Best I can do is send it a sigkill. 329 - * perhaps it should be put in the status that it wants to 330 - * exit. 331 - */ 332 - case PTRACE_KILL: 333 - ret = 0; 334 - if (child->exit_state == EXIT_ZOMBIE) 335 - break; 336 - child->exit_code = SIGKILL; 337 - /* make sure single-step breakpoint is gone. */ 338 - ptrace_cancel_bpt(child); 339 - wake_up_process(child); 340 - break; 341 - 342 - case PTRACE_SINGLESTEP: /* execute single instruction. */ 343 - ret = -EIO; 344 - if (!valid_signal(data)) 345 - break; 346 - /* Mark single stepping. */ 347 - task_thread_info(child)->bpt_nsaved = -1; 348 - clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); 349 - child->exit_code = data; 350 - wake_up_process(child); 351 - /* give it a chance to run. */ 352 - ret = 0; 353 - break; 354 - 355 298 default: 356 299 ret = ptrace_request(child, request, addr, data); 357 300 break;