Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1bd09508 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Linus Torvalds
Browse files

um: 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.

XXX: I'm not sure arch_has_single_step() is placed in the exactly correct
location, please verify in which of the ptrace headers it should really
be.

Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Roland McGrath <roland@redhat.com>
Cc: Jeff Dike <jdike@addtoit.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 55436c91
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -16,6 +16,8 @@ struct pt_regs {
	struct uml_pt_regs regs;
	struct uml_pt_regs regs;
};
};


#define arch_has_single_step()	(1)

#define EMPTY_REGS { .regs = EMPTY_UML_PT_REGS }
#define EMPTY_REGS { .regs = EMPTY_UML_PT_REGS }


#define PT_REGS_IP(r) UPT_IP(&(r)->regs)
#define PT_REGS_IP(r) UPT_IP(&(r)->regs)
+16 −54
Original line number Original line Diff line number Diff line
@@ -12,16 +12,25 @@
#endif
#endif
#include "skas_ptrace.h"
#include "skas_ptrace.h"


static inline void set_singlestepping(struct task_struct *child, int on)


void user_enable_single_step(struct task_struct *child)
{
{
	if (on)
	child->ptrace |= PT_DTRACE;
	child->ptrace |= PT_DTRACE;
	else
	child->thread.singlestep_syscall = 0;

#ifdef SUBARCH_SET_SINGLESTEPPING
	SUBARCH_SET_SINGLESTEPPING(child, 1);
#endif
}

void user_disable_single_step(struct task_struct *child)
{
	child->ptrace &= ~PT_DTRACE;
	child->ptrace &= ~PT_DTRACE;
	child->thread.singlestep_syscall = 0;
	child->thread.singlestep_syscall = 0;


#ifdef SUBARCH_SET_SINGLESTEPPING
#ifdef SUBARCH_SET_SINGLESTEPPING
	SUBARCH_SET_SINGLESTEPPING(child, on);
	SUBARCH_SET_SINGLESTEPPING(child, 0);
#endif
#endif
}
}


@@ -30,7 +39,7 @@ static inline void set_singlestepping(struct task_struct *child, int on)
 */
 */
void ptrace_disable(struct task_struct *child)
void ptrace_disable(struct task_struct *child)
{
{
	set_singlestepping(child,0);
	user_disable_single_step(child);
}
}


extern int peek_user(struct task_struct * child, long addr, long data);
extern int peek_user(struct task_struct * child, long addr, long data);
@@ -69,53 +78,6 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
		ret = -EIO;
		ret = -EIO;
		break;
		break;


	/* continue and stop at next (return from) syscall */
	case PTRACE_SYSCALL:
	/* restart after signal. */
	case PTRACE_CONT: {
		ret = -EIO;
		if (!valid_signal(data))
			break;

		set_singlestepping(child, 0);
		if (request == PTRACE_SYSCALL)
			set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
		else clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
		child->exit_code = data;
		wake_up_process(child);
		ret = 0;
		break;
	}

/*
 * make the child exit.  Best I can do is send it a sigkill.
 * perhaps it should be put in the status that it wants to
 * exit.
 */
	case PTRACE_KILL: {
		ret = 0;
		if (child->exit_state == EXIT_ZOMBIE)	/* already dead */
			break;

		set_singlestepping(child, 0);
		child->exit_code = SIGKILL;
		wake_up_process(child);
		break;
	}

	case PTRACE_SINGLESTEP: {  /* set the trap flag. */
		ret = -EIO;
		if (!valid_signal(data))
			break;
		clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
		set_singlestepping(child, 1);
		child->exit_code = data;
		/* give it a chance to run. */
		wake_up_process(child);
		ret = 0;
		break;
	}

#ifdef PTRACE_GETREGS
#ifdef PTRACE_GETREGS
	case PTRACE_GETREGS: { /* Get all gp regs from the child. */
	case PTRACE_GETREGS: { /* Get all gp regs from the child. */
		if (!access_ok(VERIFY_WRITE, p, MAX_REG_OFFSET)) {
		if (!access_ok(VERIFY_WRITE, p, MAX_REG_OFFSET)) {