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.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/sched.hlinux/sched/task_stack.hlinux/mm.hlinux/smp.hlinux/errno.hlinux/ptrace.hlinux/user.hlinux/security.hlinux/signal.hlinux/audit.hlinux/seccomp.hasm/syscall.hlinux/uaccess.hasm/fpu.hproto.hlinux/uio.h
Detected Declarations
function get_reg_addrfunction get_regfunction put_regfunction read_intfunction write_intfunction ptrace_set_bptfunction ptrace_cancel_bptfunction user_enable_single_stepfunction user_disable_single_stepfunction ptrace_disablefunction arch_ptracefunction testsfunction syscall_trace_enterfunction syscall_trace_leave
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
- Immediate include surface: `linux/kernel.h`, `linux/sched.h`, `linux/sched/task_stack.h`, `linux/mm.h`, `linux/smp.h`, `linux/errno.h`, `linux/ptrace.h`, `linux/user.h`.
- Detected declarations: `function get_reg_addr`, `function get_reg`, `function put_reg`, `function read_int`, `function write_int`, `function ptrace_set_bpt`, `function ptrace_cancel_bpt`, `function user_enable_single_step`, `function user_disable_single_step`, `function ptrace_disable`.
- Atlas domain: Architecture Layer / arch/alpha.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.