-
-
Notifications
You must be signed in to change notification settings - Fork 169
feat(ptrace): 初步实现ptrace系统调用(1/2),并完善信号处理机制 #1663
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
strace & RawPid Signed-off-by: aLinChe <1129332011@qq.com>
Signed-off-by: aLinChe <1129332011@qq.com>
Signed-off-by: aLinChe <1129332011@qq.com>
Signed-off-by: aLinChe <1129332011@qq.com>
主要改进: - 重构信号权限检查,统一使用check_kill_permission函数 - 修复wait系统调用对ptrace子进程的支持,包括TracedStopped状态处理 - 完善ptrace_signal函数,修复潜在的use-after-free问题 - 改进exit_signal时序,确保waitid后进程资源立即释放 - 修复ProcessState::Stopped状态存储实际停止信号号 - 增强错误处理,避免panic风险
Signed-off-by: aLinChe <1129332011@qq.com>
|
2 months ago... |
Signed-off-by: aLinChe <1129332011@qq.com>
Signed-off-by: aLinChe <1129332011@qq.com>
|
@claude review |
|
Claude finished @fslongjin's task in 5m 59s —— View job Claude Code Review - PR #1663: feat(ptrace): 初步实现ptrace系统调用并完善信号处理机制I've completed a thorough review of this PR implementing ptrace system calls and signal handling improvements. Here's my assessment: Todo List:
Overall AssessmentThis is a substantial and well-structured implementation of Linux-compatible ptrace functionality. The code follows Linux 6.6.21 semantics closely and provides a solid foundation for debugging tools like gdb and strace. The implementation covers core ptrace operations with good attention to security and correctness. Strengths
Issues and Concerns1. Incomplete Implementations (TODOs)
2. Safety and Robustness Issues
3. Architectural Concerns
4. Code Quality Issues
Specific Code IssuesCritical Safety Issues:
Incomplete Features:
CI StatusTest Results: 97/98 tests passed (98.98% success rate) The test failure appears to be in RecommendationsHigh Priority:
Medium Priority:
Testing:
ConclusionThis PR represents significant progress toward Linux-compatible debugging support. The core architecture is sound and follows Linux semantics well. With attention to the safety issues and completion of the TODOs, this will be a valuable addition to DragonOS. The implementation is ready for merge with the understanding that some features remain incomplete and will need follow-up work. The safety issues should be addressed before widespread use in production environments. Recommended Action: Merge with notes about the outstanding TODOs and safety considerations. |
feat(ptrace): 初步实现ptrace系统调用并完善信号处理机制
概述
本PR实现了Linux兼容的ptrace系统调用,包括进程跟踪、信号拦截、系统调用监控等核心功能。实现严格遵循Linux 6.6.21源码语义,为DragonOS提供初步的调试器支持(如gdb、strace)的能力。
主要功能
1. PTRACE_TRACEME 完整实现
2. PTRACE_ATTACH / PTRACE_DETACH 完整实现
3. PTRACE_SYSCALL 部分实现
4. PTRACE_PEEKDATA / PTRACE_POKEDATA 部分实现
5. PTRACE_GETREGS 部分实现
核心实现
新增文件
kernel/src/process/ptrace.rs- ptrace核心逻辑kernel/src/process/syscall/sys_ptrace.rs- ptrace系统调用入口user/apps/c_unitest/test_ptrace.c- ptrace功能测试用例修改文件
kernel/src/process/mod.rs- 添加ptrace相关进程状态管理kernel/src/process/exit.rs- 处理被跟踪进程的退出通知kernel/src/arch/x86_64/syscall/mod.rs- 系统调用拦截支持kernel/src/ipc/signal.rs- 信号处理与ptrace集成kernel/src/ipc/signal_types.rs- 添加ptrace相关的siginfo类型定义测试验证
测试用例输出(与Linux 6.6.21行为一致)
后续工作