arch/alpha/kernel/ptrace.c

Source file repositories/reference/linux-study-clean/arch/alpha/kernel/ptrace.c

File Facts

System
Linux kernel
Corpus path
arch/alpha/kernel/ptrace.c
Extension
.c
Size
10887 bytes
Lines
413
Domain
Architecture Layer
Bucket
arch/alpha
Inferred role
Architecture Layer: implementation source
Status
source implementation candidate

Why This File Exists

CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.

Dependency Surface

Detected Declarations

Annotated Snippet

if (addr != NT_PRSTATUS) {
			ret = -EIO;
			break;
		}

		if (copy_from_user(&iov, uiov, sizeof(iov))) {
			ret = -EFAULT;
			break;
		}

		regs = task_pt_regs(child);
		len = min_t(size_t, iov.iov_len, sizeof(*regs));

		if (request == PTRACE_GETREGSET) {
			if (copy_to_user(iov.iov_base, regs, len)) {
				ret = -EFAULT;
				break;
			}
		} else {
		/*
		 * Allow writing back regs. This is needed by the TRACE_syscall
		 * tests (they change PC/syscall nr/retval).
		 */
			if (copy_from_user(regs, iov.iov_base, len)) {
				ret = -EFAULT;
				break;
			}
		}

		/* Per API, update iov_len with amount transferred. */
		iov.iov_len = len;
		if (copy_to_user(uiov, &iov, sizeof(iov))) {
			ret = -EFAULT;
			break;
		}

		ret = 0;
		break;
	}

	default:
		ret = ptrace_request(child, request, addr, data);
		break;
	}
	return ret;
}

asmlinkage unsigned long syscall_trace_enter(void)
{
	struct pt_regs *regs = current_pt_regs();

	if (test_thread_flag(TIF_SYSCALL_TRACE) &&
		ptrace_report_syscall_entry(regs)) {
		syscall_set_nr(current, regs, -1);
		if (regs->r19 == 0 && regs->r0 == (unsigned long)-1)
			syscall_set_return_value(current, regs, -ENOSYS, 0);
		return -1UL;
	}

	/*
	 * Do the secure computing after ptrace; failures should be fast.
	 * If this fails, seccomp may already have set up the return value
	 * (e.g. SECCOMP_RET_ERRNO / TRACE).
	 */
	if (secure_computing() == -1) {
		if (regs->r19 == 0 && regs->r0 == (unsigned long)-1)
			syscall_set_return_value(current, regs, -ENOSYS, 0);
		syscall_set_nr(current, regs, -1);
		return -1UL;
	}

#ifdef CONFIG_AUDITSYSCALL
	audit_syscall_entry(syscall_get_nr(current, regs),
		regs->r16, regs->r17, regs->r18, regs->r19);
#endif
	return syscall_get_nr(current, regs);
}



asmlinkage void
syscall_trace_leave(void)
{
	audit_syscall_exit(current_pt_regs());
	if (test_thread_flag(TIF_SYSCALL_TRACE))
		ptrace_report_syscall_exit(current_pt_regs(), 0);
}

Annotation

Implementation Notes