ret = security_ptrace(current->parent, current); if (ret) goto out; /* set the ptrace bit in the process flags. */ 
sys_ptrace(long request, long pid, long addr, long data){	struct task_struct *child;	int ret;	unsigned long __user *datap = (unsigned long __user *)data;	lock_kernel();	ret = -EPERM;		if (request == PTRACE_TRACEME) {		if (current->ptrace & PT_PTRACED)			goto out;		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)		/* Leave the init process alone! */		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) {		/* Read word at location address. */ 		case PTRACE_PEEKTEXT:		case PTRACE_PEEKDATA: {			unsigned long tmp;			int copied;			copied = access_process_vm(child, addr, &tmp, sizeof(tmp), 0);			ret = -EIO;						if (copied != sizeof(tmp))				break;						ret = put_user(tmp,datap);			break;		}		/* Read the word at location address in the USER area. */		case PTRACE_PEEKUSR: {			unsigned long tmp;			ret = -EIO;			if ((addr & 3) || addr < 0 || addr > PT_MAX << 2)				break;			tmp = get_reg(child, addr >> 2);			ret = put_user(tmp, datap);			break;		}				/* Write the word at location address. */		case PTRACE_POKETEXT:		case PTRACE_POKEDATA:			ret = 0;						if (access_process_vm(child, addr, &data, sizeof(data), 1) == sizeof(data))				break;						ret = -EIO;			break;  		/* Write the word at location address in the USER area. */		case PTRACE_POKEUSR:			ret = -EIO;			if ((addr & 3) || addr < 0 || addr > PT_MAX << 2)				break;			addr >>= 2;			if (addr == PT_DCCR) {				/* don't allow the tracing process to change stuff like				 * interrupt enable, kernel/user bit, dma enables etc.				 */				data &= DCCR_MASK;				data |= get_reg(child, PT_DCCR) & ~DCCR_MASK;			}			if (put_reg(child, addr, data))				break;			ret = 0;			break;		case PTRACE_SYSCALL:		case PTRACE_CONT:			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;						/* TODO: make sure any pending breakpoint is killed */			wake_up_process(child);			ret = 0;						break;		 		/* Make the child exit by sending it a sigkill. */		case PTRACE_KILL:			ret = 0;						if (child->state == TASK_ZOMBIE)				break;						child->exit_code = SIGKILL;						/* TODO: make sure any pending breakpoint is killed */			wake_up_process(child);			break;		/* Set the trap flag. */		case PTRACE_SINGLESTEP:			ret = -EIO;						if (!valid_signal(data))				break;						clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);			/* TODO: set some clever breakpoint mechanism... */			child->exit_code = data;			wake_up_process(child);			ret = 0;			break;		case PTRACE_DETACH:			ret = ptrace_detach(child, data);			break;		/* Get all GP registers from the child. */		case PTRACE_GETREGS: {		  	int i;			unsigned long tmp;						for (i = 0; i <= PT_MAX; i++) {				tmp = get_reg(child, i);								if (put_user(tmp, datap)) {					ret = -EFAULT;					goto out_tsk;				}								data += sizeof(long);			}			ret = 0;			break;		}		/* Set all GP registers in the child. */		case PTRACE_SETREGS: {			int i;			unsigned long tmp;						for (i = 0; i <= PT_MAX; i++) {				if (get_user(tmp, datap)) {					ret = -EFAULT;					goto out_tsk;				}								if (i == PT_DCCR) {					tmp &= DCCR_MASK;					tmp |= get_reg(child, PT_DCCR) & ~DCCR_MASK;				}								put_reg(child, i, tmp);				data += sizeof(long);			}						ret = 0;			break;		}		default:			ret = ptrace_request(child, request, addr, data);			break;	}out_tsk:	put_task_struct(child);out:	unlock_kernel();	return ret;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/5d01e6ce785884a5db5792cd2e5bb36fa82fe23c/ptrace.c/buggy/arch/cris/arch-v10/kernel/ptrace.c