case 0 ... sizeof(struct user_regs_struct): 
case 0 ... sizeof(struct user_regs_struct) - sizeof(long): 
asmlinkage long sys_ptrace(long request, long pid, unsigned long addr, long data){	struct task_struct *child;	long i, ret;	unsigned ui;	/* This lock_kernel fixes a subtle race with suid exec */	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: {		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,(unsigned long __user *) data);		break;	}	/* read the word at location addr in the USER area. */	case PTRACE_PEEKUSR: {		unsigned long tmp;		ret = -EIO;		if ((addr & 7) ||		    addr > sizeof(struct user) - 7)			break;		switch (addr) { 		case 0 ... sizeof(struct user_regs_struct):			tmp = getreg(child, addr);			break;		case offsetof(struct user, u_debugreg[0]):			tmp = child->thread.debugreg0;			break;		case offsetof(struct user, u_debugreg[1]):			tmp = child->thread.debugreg1;			break;		case offsetof(struct user, u_debugreg[2]):			tmp = child->thread.debugreg2;			break;		case offsetof(struct user, u_debugreg[3]):			tmp = child->thread.debugreg3;			break;		case offsetof(struct user, u_debugreg[6]):			tmp = child->thread.debugreg6;			break;		case offsetof(struct user, u_debugreg[7]):			tmp = child->thread.debugreg7;			break;		default:			tmp = 0;			break;		}		ret = put_user(tmp,(unsigned long __user *) 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 = 0;		if (access_process_vm(child, addr, &data, sizeof(data), 1) == sizeof(data))			break;		ret = -EIO;		break;	case PTRACE_POKEUSR: /* write the word at location addr in the USER area */		ret = -EIO;		if ((addr & 7) ||		    addr > sizeof(struct user) - 7)			break;		switch (addr) { 		case 0 ... sizeof(struct user_regs_struct): 			ret = putreg(child, addr, data);			break;		/* Disallows to set a breakpoint into the vsyscall */		case offsetof(struct user, u_debugreg[0]):			if (data >= TASK_SIZE-7) break;			child->thread.debugreg0 = data;			ret = 0;			break;		case offsetof(struct user, u_debugreg[1]):			if (data >= TASK_SIZE-7) break;			child->thread.debugreg1 = data;			ret = 0;			break;		case offsetof(struct user, u_debugreg[2]):			if (data >= TASK_SIZE-7) break;			child->thread.debugreg2 = data;			ret = 0;			break;		case offsetof(struct user, u_debugreg[3]):			if (data >= TASK_SIZE-7) break;			child->thread.debugreg3 = data;			ret = 0;			break;		case offsetof(struct user, u_debugreg[6]):				  if (data >> 32)				break; 			child->thread.debugreg6 = data;			ret = 0;			break;		case offsetof(struct user, u_debugreg[7]):			/* See arch/i386/kernel/ptrace.c for an explanation of			 * this awkward check.*/				  data &= ~DR_CONTROL_RESERVED;				  for(i=0; i<4; i++)					  if ((0x5454 >> ((data >> (16 + 4*i)) & 0xf)) & 1)					break;			if (i == 4) {				child->thread.debugreg7 = data;			  ret = 0;		  }		  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);		clear_tsk_thread_flag(child, TIF_SINGLESTEP);		child->exit_code = data;		/* make sure the single step bit is not set. */		clear_singlestep(child);		wake_up_process(child);		ret = 0;		break;#ifdef CONFIG_IA32_EMULATION		/* This makes only sense with 32bit programs. Allow a		   64bit debugger to fully examine them too. Better		   don't use it against 64bit processes, use		   PTRACE_ARCH_PRCTL instead. */	case PTRACE_SET_THREAD_AREA: {		struct user_desc __user *p;		int old; 		p = (struct user_desc __user *)data;		get_user(old,  &p->entry_number); 		put_user(addr, &p->entry_number);		ret = do_set_thread_area(&child->thread, p);		put_user(old,  &p->entry_number); 		break;	case PTRACE_GET_THREAD_AREA:		p = (struct user_desc __user *)data;		get_user(old,  &p->entry_number); 		put_user(addr, &p->entry_number);		ret = do_get_thread_area(&child->thread, p);		put_user(old,  &p->entry_number); 		break;	} #endif		/* normal 64bit interface to access TLS data. 		   Works just like arch_prctl, except that the arguments		   are reversed. */	case PTRACE_ARCH_PRCTL: 		ret = do_arch_prctl(child, data, addr);		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;		clear_tsk_thread_flag(child, TIF_SINGLESTEP);		child->exit_code = SIGKILL;		/* make sure the single step bit is not set. */		clear_singlestep(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);		set_singlestep(child);		child->exit_code = data;		/* give it a chance to run. */		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 gp regs from the child. */	  	if (!access_ok(VERIFY_WRITE, (unsigned __user *)data,			       sizeof(struct user_regs_struct))) {			ret = -EIO;			break;		}		ret = 0;		for (ui = 0; ui < sizeof(struct user_regs_struct); ui += sizeof(long)) {			ret |= __put_user(getreg(child, ui),(unsigned long __user *) data);			data += sizeof(long);		}		break;	}	case PTRACE_SETREGS: { /* Set all gp regs in the child. */		unsigned long tmp;	  	if (!access_ok(VERIFY_READ, (unsigned __user *)data,			       sizeof(struct user_regs_struct))) {			ret = -EIO;			break;		}		ret = 0;		for (ui = 0; ui < sizeof(struct user_regs_struct); ui += sizeof(long)) {			ret |= __get_user(tmp, (unsigned long __user *) data);			putreg(child, ui, tmp);			data += sizeof(long);		}		break;	}	case PTRACE_GETFPREGS: { /* Get the child extended FPU state. */		if (!access_ok(VERIFY_WRITE, (unsigned __user *)data,			       sizeof(struct user_i387_struct))) {			ret = -EIO;			break;		}		ret = get_fpregs((struct user_i387_struct __user *)data, child);		break;	}	case PTRACE_SETFPREGS: { /* Set the child extended FPU state. */		if (!access_ok(VERIFY_READ, (unsigned __user *)data,			       sizeof(struct user_i387_struct))) {			ret = -EIO;			break;		}		set_stopped_child_used_math(child);		ret = set_fpregs(child, (struct user_i387_struct __user *)data);		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/c4d1fcf3a2ea89b6d6221fa8b4588c77aff50995/ptrace.c/buggy/arch/x86_64/kernel/ptrace.c