aLinCheandlongjin 5a0707b6b2 feat(ptrace): implement Linux-compatible tracing and remote access (#2198)
feat(ptrace): implement Linux-compatible tracing and remote access

Implement a Linux 6.6-compatible ptrace subsystem and integrate it with
signal delivery, syscall dispatch, seccomp, process lifecycle events,
wait semantics, remote memory access, x86 debug traps, and uprobes.

Replace the original monolithic implementation with ownership-oriented
modules:

- define ptrace ABI types, options, events, and syscall-info separately;
- model active stops, pending events, completed resumes, and request
  freezes as typed state with explicit generation ownership;
- maintain bidirectional tracer relationships with O(1) slot-based
  link and unlink operations;
- centralize attach, seize, detach, wait, exit, fork, group-stop, and
  SIGCONT transactions in the lifecycle layer;
- expose registers, siginfo, sigmask, event messages, and remote memory
  only through a session-and-stop-generation-bound request guard.

Make tracing lifecycle transitions race-safe:

- bind stops, events, waits, debug handoffs, and fork inheritance to the
  exact tracing session that created them;
- wait for the tracee to become inactive before accessing its kernel
  stack TrapFrame;
- revoke request freezes and replay deferred fatal wakeups exactly once;
- preserve group-stop state across detach and tracer exit;
- prevent EXITKILL, EXEC, SECCOMP, SIGCONT, and pending-stop events from
  leaking into a replacement tracing session;
- hand traced zombies from exactly one tracer waiter to the real parent;
- prepare fallible allocations outside IRQ-disabled relation
  transactions and commit only after capacity and ownership revalidation.

Implement the ptrace execution and event ABI, including TRACEME, ATTACH,
SEIZE, DETACH, CONT, SYSCALL, SINGLESTEP, SYSEMU, INTERRUPT, LISTEN,
GET/SETREGS, NT_PRSTATUS GET/SETREGSET, PEEK/POKEUSER, signal and sigmask
access, event messages, syscall information, and fork/clone/vfork,
exec, exit, seccomp, and group-stop events.

Introduce a shared remote-memory engine for ptrace, /proc/<pid>/mem, and
process_vm_readv/writev. Preserve Linux permission checks, precise short
copy results, forced-access COW, MAP_PRIVATE isolation, shared
page-cache dirty accounting, and RISC-V executable-memory I-cache
synchronization. Continue rejecting unsupported special or external-PFN
VMAs instead of adding an unsafe generic provider workaround.

Complete x86_64 tracing state support:

- virtualize and context-switch hardware debug registers;
- coordinate #BP/#DB routing between ptrace and uprobe XOL execution;
- preserve hardware breakpoint, watchpoint, single-step, DR6, and RF
  semantics;
- validate and restore CS, SS, DS, ES, FS, and GS selectors according to
  Linux rules;
- preserve FS/GS selectors and bases across ptrace writes, context
  switches, signal return, and VMX host transitions;
- recover safely from missing data descriptors and preserve the original
  fault frame on invalid iret selectors.

Align siginfo conversion, tracer identity, syscall-number rewriting,
regset partial-copy behavior, dumpability, user-namespace capability
checks, Yama policy, and procfs TracerPid reporting with Linux 6.6.

Add deterministic dunitest and gVisor coverage for ptrace lifecycle,
group-stop, concurrent ownership, EXITKILL, syscall information,
seccomp TRACE, x86 debug state, segment registers, process_vm access,
proc-mem, page-cache persistence, and remote I-cache synchronization.
Remove the ptrace Int3 blocklist and declare only the verified
INT3:TRUE gVisor platform capability.

Validation on the final head includes:

- x86_64, RISC-V, and LoongArch build, format, and static checks;
- successful x86_64 Dunitest and integration workflows;
- 1172 local Ubuntu 24.04 two-vCPU dunitests with 0 failures and
  0 timeouts;
- 12/12 targeted x86 ptrace register/debug tests on both Linux and
  DragonOS;
- successful MM host tests and final adversarial architecture,
  correctness, concurrency, security, and performance review.

PTRACE_O_SUSPEND_SECCOMP and non-NT_PRSTATUS regsets remain explicitly
unsupported. Remote access to special/external-PFN VMAs continues to
require a future safe provider contract.


Signed-off-by: aLinChe <1129332011@qq.com>
Signed-off-by: longjin <longjin@dragonos.org>
Co-authored-by: longjin <longjin@dragonos.org>
2026-08-28 16:42:48 +08:00
2022-01-16 22:58:21 +08:00

dragonos-logo

Lightweight Cloud-Native Kernel

官网 bbs

DragonOS

Languages 中文|English  

DragonOS is a 64-bit operating system with a completely independent kernel, designed for lightweight cloud computing scenarios, offering Linux binary compatibility. It aims to provide lightweight, high-performance solutions for containerized workloads. Developed using Rust for enhanced reliability.

The DragonOS open-source community was established in July 2022 and is entirely commercially neutral. We warmly welcome interested developers and enthusiasts to join us!

DragonOS features excellent and comprehensive architectural design. Compared to other systems of similar scale, DragonOS supports eBPF and virtualization. Currently, we are actively advancing container support, cloud platform compatibility, RISC-V support, as well as porting compilers and application software. Our goal is to achieve large-scale production environment deployment within five years.

DragonOS is rapidly evolving under community-driven development. Currently, DragonOS has implemented approximately 1/4 of Linux interfaces. In the future, we will provide 100% Linux compatibility along with new features.

🌟 Want to quickly experience DragonOS? Visit DragonOS Playground to launch DragonOS in the cloud with zero configuration and experience the latest nightly build!

📰 Community News

  • 2025-12-17: ☁️ DragonOS Playground is now live! Experience DragonOS with zero configuration on CNB platform, with daily nightly build updates! Try it now →
  • 2025-11-20: 🚀 DragonOS 0.3.0 has been released! Now supports running Go programs directly!
  • 2025-11-18: 📊 DragonOS CI Dashboard is now live! Check out DragonOS Linux compatibility data now!

How to Run?

Zero configuration, one-click launch! Experience DragonOS on the CNB cloud-native development platform - the simplest and fastest way, no local dependencies required!

Launch on CNB

Method 2: Local Build

If you prefer to build and run DragonOS locally, you can refer to the following documentation:

Want to Contribute?

Read the DragonOS Community Introduction Document carefully to understand how the community operates and how you can contribute!

If you'd like to join us, check out the issues and participate in discussions or share your ideas. You can also visit the DragonOS forum to stay updated on development progress and tasks: https://bbs.dragonos.org.cn

You can also bring your creativity and ideas to discuss with the community and contribute new features to DragonOS.

Sites

How to Connect with the Community?

Please read the Contributor Guide~

  • You can find contact details for members of various committees in the Community Management Team section.
  • You can also locate the contact information for leaders of specific community groups via the SIGs and WGs pages.

Contributor List

Contributors to DragonOS-Community/DragonOS · GitHub

Sponsorship

Sponsor this project

DragonOS is a non-profit open-source project, and its development relies on financial support. All sponsors will be publicly acknowledged. Every contribution you make will help advance DragonOS!

Where Will Sponsorship Funds Be Used?

We guarantee that all sponsorship funds and items will be used for:

  • Event organization, cloud service expenses, and any other purposes beneficial to the development and growth of the DragonOS community.

🌟 Sponsor List

Special thanks to these generous financial supporters (in reverse chronological order):

CDN Sponsor

This project's CDN acceleration and security protection are sponsored by Tencent EdgeOne.

腾讯EdgeOne CDN

Individual Sponsors List

See Supporters.md

Open Source License Notice

This project is open-sourced under the GPLv2 license. You are welcome to use the code in compliance with the open-source license!

If you encounter any violations of the open-source license, we encourage you to email pmc@dragonos.org to report them. Let's work together to build a trustworthy open-source community.


👩💻 Contributors

"Open source shines because of you!"

Thanks to all developers who submitted code, fixed issues, or reviewed PRs:

S
Description
使用Rust从0自研内核,具有Linux兼容性的操作系统,面向云计算Serverless场景而设计。DragonOS is an operating system developed from scratch using Rust, with Linux compatibility. It is designed for **Serverless** scenarios.
Readme GPL-2.0
196 MiB
Languages
Rust 75.4%
C++ 16.1%
C 4.1%
Python 2%
Shell 1.6%
Other 0.7%