procfs: PTRACE_O_TRACESYSGOOD (fake)
This commit is contained in:
committed by
Tomoki Shirasawa
parent
fef946e5ff
commit
f0f31e19fb
@ -59,8 +59,8 @@
|
||||
|
||||
#define PS_NORMAL (PS_INTERRUPTIBLE | PS_UNINTERRUPTIBLE)
|
||||
|
||||
#define PT_TRACED 0x1 /* The process is ptraced */
|
||||
#define PT_TRACE_EXEC 0x2 /* Trace execve(2) */
|
||||
#define PT_TRACED 0x80 /* The process is ptraced */
|
||||
#define PT_TRACE_EXEC 0x100 /* Trace execve(2) */
|
||||
|
||||
#define PTRACE_TRACEME 0
|
||||
#define PTRACE_PEEKTEXT 1
|
||||
@ -284,7 +284,10 @@ struct fork_tree_node {
|
||||
might divert while the threads are exiting by group_exit(). */
|
||||
int group_exit_status;
|
||||
|
||||
/* Showing whether or not the process is ptraced */
|
||||
/* Store ptrace flags.
|
||||
* The lower 8 bits are PTRACE_O_xxx of the PTRACE_SETOPTIONS request.
|
||||
* Other bits are for inner use of the McKernel.
|
||||
*/
|
||||
int ptrace;
|
||||
|
||||
/* Store event related to signal. For example,
|
||||
|
||||
@ -2440,6 +2440,37 @@ static long ptrace_getregs(int pid, long data)
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int ptrace_setoptions(int pid, int flags)
|
||||
{
|
||||
int ret;
|
||||
struct process *child;
|
||||
ihk_spinlock_t *savelock;
|
||||
unsigned long irqstate;
|
||||
|
||||
/* Only supported options are enabled.
|
||||
* PTRACE_O_TRACESYSGOOD is pretended to be supported for the time being.
|
||||
*/
|
||||
if (flags & ~PTRACE_O_TRACESYSGOOD) {
|
||||
kprintf("ptrace_setoptions: not supported flag %x\n", flags);
|
||||
ret = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
child = findthread_and_lock(pid, -1, &savelock, &irqstate);
|
||||
if (!child || !child->ftn || !(child->ftn->ptrace | PT_TRACED)) {
|
||||
ret = -ESRCH;
|
||||
goto unlockout;
|
||||
}
|
||||
|
||||
child->ftn->ptrace |= flags;
|
||||
ret = 0;
|
||||
|
||||
unlockout:
|
||||
ihk_mc_spinlock_unlock(savelock, irqstate);
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
SYSCALL_DECLARE(ptrace)
|
||||
{
|
||||
const long request = (long)ihk_mc_syscall_arg0(ctx);
|
||||
@ -2470,6 +2501,10 @@ SYSCALL_DECLARE(ptrace)
|
||||
error = ptrace_pokeuser(pid, addr, data);
|
||||
dkprintf("PTRACE_POKEUSER: addr=%p data=%p return=%p\n", addr, data, error);
|
||||
break;
|
||||
case PTRACE_SETOPTIONS:
|
||||
error = ptrace_setoptions(pid, data);
|
||||
dkprintf("PTRACE_SETOPTIONS: flags=%d return=%p\n", data, error);
|
||||
break;
|
||||
default:
|
||||
dkprintf("ptrace: unimplemented ptrace called.\n");
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user