asmlinkage int sys_ptrace(long request, long pid, long addr, long data) 
asmlinkage long sys_ptrace(long request, long pid, long addr, long data) 
asmlinkage int sys_ptrace(long request, long pid, long addr, long data){	struct task_struct *child;	unsigned long tmp;	int ret;	lock_kernel();	ret = -EPERM;	if (request == PTRACE_TRACEME) {		/* are we already being traced? */		if (current->ptrace & PT_PTRACED)			goto out;		ret = security_ptrace(current->parent, current);		if (ret)			goto out;		/* set the ptrace bit in the process flags. */		current->ptrace |= PT_PTRACED;		ret = 0;		goto out;	}	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)		/* you may not mess with init */		goto out_tsk;	if (request == PTRACE_ATTACH) {		ret = ptrace_attach(child);		goto out_tsk;	}	ret = ptrace_check_attach(child, request == PTRACE_KILL);	if (ret < 0)		goto out_tsk;	switch (request) {		/* when I and D space are separate, these will need to be fixed. */	case PTRACE_PEEKTEXT: /* read word at location addr. */	case PTRACE_PEEKDATA: {		int copied;		ret = -EIO;		if (is_user_addr_valid(child, addr, sizeof(tmp)) < 0)			break;		copied = access_process_vm(child, addr, &tmp, sizeof(tmp), 0);		if (copied != sizeof(tmp))			break;		ret = put_user(tmp,(unsigned long *) data);		break;	}		/* read the word at location addr in the USER area. */	case PTRACE_PEEKUSR: {		tmp = 0;		ret = -EIO;		if ((addr & 3) || addr < 0)			break;		ret = 0;		switch (addr >> 2) {		case 0 ... PT__END - 1:			tmp = get_reg(child, addr >> 2);			break;		case PT__END + 0:			tmp = child->mm->end_code - child->mm->start_code;			break;		case PT__END + 1:			tmp = child->mm->end_data - child->mm->start_data;			break;		case PT__END + 2:			tmp = child->mm->start_stack - child->mm->start_brk;			break;		case PT__END + 3:			tmp = child->mm->start_code;			break;		case PT__END + 4:			tmp = child->mm->start_stack;			break;		default:			ret = -EIO;			break;		}		if (ret == 0)			ret = put_user(tmp, (unsigned long *) data);		break;	}		/* when I and D space are separate, this will have to be fixed. */	case PTRACE_POKETEXT: /* write the word at location addr. */	case PTRACE_POKEDATA:		ret = -EIO;		if (is_user_addr_valid(child, addr, sizeof(tmp)) < 0)			break;		if (access_process_vm(child, addr, &data, sizeof(data), 1) != sizeof(data))			break;		ret = 0;		break;	case PTRACE_POKEUSR: /* write the word at location addr in the USER area */		ret = -EIO;		if ((addr & 3) || addr < 0)			break;		ret = 0;		switch (addr >> 2) {		case 0 ... PT__END-1:			ret = put_reg(child, addr >> 2, data);			break;		default:			ret = -EIO;			break;		}		break;	case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */	case PTRACE_CONT: /* restart after signal. */		ret = -EIO;		if (!valid_signal(data))			break;		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;		ptrace_disable(child);		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;		child->exit_code = SIGKILL;		clear_tsk_thread_flag(child, TIF_SINGLESTEP);		ptrace_disable(child);		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);		ptrace_enable(child);		child->exit_code = data;		wake_up_process(child);		ret = 0;		break;	case PTRACE_DETACH:	/* detach a process that was attached. */		ret = ptrace_detach(child, data);		break;	case PTRACE_GETREGS: { /* Get all integer regs from the child. */		int i;		for (i = 0; i < PT__GPEND; i++) {			tmp = get_reg(child, i);			if (put_user(tmp, (unsigned long *) data)) {				ret = -EFAULT;				break;			}			data += sizeof(long);		}		ret = 0;		break;	}	case PTRACE_SETREGS: { /* Set all integer regs in the child. */		int i;		for (i = 0; i < PT__GPEND; i++) {			if (get_user(tmp, (unsigned long *) data)) {				ret = -EFAULT;				break;			}			put_reg(child, i, tmp);			data += sizeof(long);		}		ret = 0;		break;	}	case PTRACE_GETFPREGS: { /* Get the child FP/Media state. */		ret = 0;		if (copy_to_user((void *) data,				 &child->thread.user->f,				 sizeof(child->thread.user->f)))			ret = -EFAULT;		break;	}	case PTRACE_SETFPREGS: { /* Set the child FP/Media state. */		ret = 0;		if (copy_from_user(&child->thread.user->f,				   (void *) data,				   sizeof(child->thread.user->f)))			ret = -EFAULT;		break;	}	case PTRACE_GETFDPIC:		tmp = 0;		switch (addr) {		case PTRACE_GETFDPIC_EXEC:			tmp = child->mm->context.exec_fdpic_loadmap;			break;		case PTRACE_GETFDPIC_INTERP:			tmp = child->mm->context.interp_fdpic_loadmap;			break;		default:			break;		}		ret = 0;		if (put_user(tmp, (unsigned long *) data)) {			ret = -EFAULT;			break;		}		break;	default:		ret = -EIO;		break;	}out_tsk:	put_task_struct(child);out:	unlock_kernel();	return ret;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/dfb7dac3af623a68262536437af008ed6aba4d88/ptrace.c/buggy/arch/frv/kernel/ptrace.c