feat(starry-kernel): add unshare, procfs namespace files, and claw-code tests#1031
Conversation
Add basic unshare syscall supporting CLONE_NEWUSER flag for user namespace creation. On unshare(CLONE_NEWUSER), the process credentials are reset to nobody (65534). Flags=0 is accepted as a no-op. Unsupported flags return EINVAL. Test: claw-code/goal-01-unshare — 4/4 pass on StarryOS QEMU.
Add namespace-related procfs files to support user namespace UID/GID mapping and setgroups control. - uid_map: read/write file for UID mapping in user namespaces - gid_map: read/write file for GID mapping in user namespaces - setgroups: read/write file for setgroups allow/deny control Add Thread fields for namespace mapping state tracking.
claw-code/goal-02-uid-map: 7/7 pass on StarryOS QEMU.
claw-code/goal-03-gid-map: 7/7 pass on StarryOS QEMU.
claw-code/goal-04-setgroups: 7/7 pass on StarryOS QEMU.
Add cgroup procfs file returning "0::/" (cgroup v2 unified hierarchy root) for container detection. Used by claw doctor and claw sandbox status checks. Test: claw-code/goal-05-cgroup — 4/4 pass on StarryOS QEMU.
Shell-based integration test running claw --help, claw version, and claw doctor on StarryOS QEMU. All three commands pass (EXIT:0). Binary must be cross-compiled and placed in integration/sh/ before running: RUSTFLAGS="-C target-feature=+crt-static -C linker=rust-lld" cargo build --release --target riscv64gc-unknown-linux-musl
Replace Sh pipeline (which had no build step) with Rust pipeline. build.rs downloads the pre-compiled claw binary from GitHub Releases and embeds it into the test runner binary. At runtime the runner extracts and executes claw for smoke + diagnostic checks.
- Add robustness test cases robust-01 through robust-11 with Rust pipeline - Update integration test with full functional/project steps and retry logic - Replace all hardcoded API credentials with option_env!() build-time vars - Add CLAW_API_KEY secret passthrough in CI reusable workflow
The script injected claw into target/rootfs/ but quick-start boots from tmp/axbuild/rootfs/. Changed to build first, inject into the correct path, then run — build system skips re-extraction since image exists.
Spawns 2 parallel sub-agents via --allowedTools bash,write,Agent. Sub-agent 1 creates /tmp/work/a.txt, sub-agent 2 creates /tmp/work/b.txt, then merges both into /tmp/work/merged.txt.
c93c105 to
b5e1edd
Compare
There was a problem hiding this comment.
PR #1031 Review Summary
变更概述
本 PR 为 claw-code (AI coding agent) 在 StarryOS 上的运行添加内核支持,主要包含:
- unshare() syscall,支持 CLONE_NEWUSER 标志
- /proc/self/{uid_map, gid_map, setgroups} procfs 文件
- /proc/[pid]/cgroup procfs 文件
- mount syscall 的 null fs_type 处理修复
- claw-code app 注册和大量测试(goal-01
05, integration, robust-0112)
本地验证结果
- cargo fmt --check: ✅ 通过
- cargo clippy --manifest-path os/StarryOS/kernel/Cargo.toml --all-features -- -D warnings: ✅ 通过,无警告
重复/重叠分析
- base 分支已有 cgroup2 支持(PR #989),本 PR 新增的 /proc/[pid]/cgroup 文件是独立的 procfs 入口,与 cgroup2 fs 不重复
- open PR #1032(waitid P_PGID)和 #1029(axbacktrace)与本 PR 无重叠
- mount.rs 中的 MS_REMOUNT/MS_BIND/MS_MOVE/mount propagation 支持已在 base 分支存在(PR #876, #989),本 PR 仅新增 null fs_type 处理
以下问题需要修改:
[阻塞] uid_map 写入实现语义不正确
proc.rs 中 uid_map 的写入实现直接将凭证的 uid/euid/suid/fsuid 设置为解析的第二个字段值,完全忽略了 Linux uid_map 的实际映射语义。在 Linux 中,uid_map 格式为 lower_uid upper_uid count,表示命名空间之间的 UID 映射关系。当前实现相当于直接覆盖凭证,而非创建映射表。
虽然 StarryOS 不需要完整命名空间支持,但当前实现对 "0 0 1" 之外的任何输入(如 "0 1000 1")都会产生错误行为。建议至少在代码注释中明确说明这是故意的简化行为,或者实现一个最小化的映射验证逻辑。
同理 gid_map 存在相同问题。
[阻塞] 测试二进制从第三方 fork Release 下载,存在供应链风险
integration/rust/build.rs 和 apps/starry/claw-code/prebuild.sh 从 https://github.com/MuZhao2333/tgoskits/releases/download/claw-code-binary/claw 下载预编译二进制。该 URL 指向贡献者个人 fork 的 Release,而非 rcore-os/tgoskits 主仓库。CI 中从不受信任的第三方源下载并执行二进制存在安全风险。
建议:将 claw 二进制上传到 rcore-os/tgoskits 的 Release 或其他受信任的 artifact 存储中,或改为从源码编译。
[阻塞] goal 测试缺少 x86_64 配置,PR 描述声称 x86_64 全通过不准确
test-suit/starryos/normal/qemu-smp1/claw-code/goal-01~05 仅有 qemu-riscv64.toml,没有 qemu-x86_64.toml。这意味着这些 C 测试用例仅在 riscv64 上验证。而 integration/robust 测试虽有 x86_64 配置,但依赖 CLAW_API_KEY,未配置时自动跳过(CLAW_SKIP)。因此在无 API key 的环境中,claw-code 相关的 syscall 测试在 x86_64 上完全没有覆盖。
PR 描述声称 "CI starry qemu 测试全部通过 (x86_64, aarch64, riscv64, loongarch64)" 不准确,因为 goal 测试仅覆盖 riscv64。
建议:为 goal-01~05 添加 qemu-x86_64.toml 配置文件,确保 syscall 级别的测试在 x86_64 上也能运行。
[阻塞] PR 描述声称的功能与实际 diff 不符
PR 描述声称"扩展 mount syscall:支持 MS_REMOUNT、MS_BIND、MS_MOVE、mount propagation"和"修复 umount2 的 UMOUNT_NOFOLLOW 支持和 EBUSY 检测"。但这些功能已在 base 分支存在(PR #876 和 #989),本 PR 的实际 mount.rs 改动仅为 null fs_type 指针处理(6 行代码)。请修正 PR 描述,仅列出本 PR 实际新增的内容。
[建议] robust 测试 timeout = 1800 秒过长
robust-01~12 的 QEMU 配置 timeout = 1800(30 分钟),共 12 个测试用例。若全部执行,总计需要最多 6 小时的 CI 时间。建议将单个测试的超时缩短到合理范围(如 300 秒),或在 CI 中将这些测试标记为 opt-in。
[建议] test_framework.h 重复 5 份
test_framework.h 在 goal-01~05 中各有一份完全相同的副本。建议提取为共享文件(如 test-suit/starryos/normal/qemu-smp1/claw-code/common/test_framework.h),通过 CMakeLists.txt 引用,减少维护成本。
[建议] unshare() 接受 CLONE_NEWPID/CLONE_NEWNET 等标志但静默返回成功
虽然文档说明这些标志是 no-op,但静默成功可能掩盖调用方的逻辑错误。建议对实际不创建隔离的标志输出 warn!() 日志,方便调试。
Powered by mimo-v2.5-pro
… uid_map semantics, warn on unshare no-ops
There was a problem hiding this comment.
PR #1031 复审总结
变更概述
本 PR 为 claw-code (AI coding agent) 在 StarryOS 上的运行添加内核支持:
unshare()syscall,支持CLONE_NEWUSER(其他 namespace 标志为 no-op,输出 warn 日志)/proc/self/{uid_map, gid_map, setgroups}procfs 文件(简化语义,注释已标注)/proc/[pid]/cgroupprocfs 文件- mount syscall 的 null
fs_type指针处理修复 - claw-code app 注册和测试(goal-01
05, integration, robust-0112)
作者在前次 review 后已修复以下问题:
- ✅ uid_map/gid_map 简化语义已在代码注释中明确标注
- ✅ 新增 x86_64 配置文件(但有 TOML 解析错误,见下方阻塞项)
- ✅ unshare() 的 no-op 标志现在输出 warn 日志
- ✅ PR 描述已更新,不再声称属于 base 分支的功能
本地验证结果
cargo fmt --check: ❌namespace.rs:36有一处格式问题cargo clippy --manifest-path os/StarryOS/kernel/Cargo.toml --all-features -- -D warnings: ✅ 通过cargo xtask starry test qemu --list --arch x86_64: ❌ goal-01~05 的 x86_64 TOML 全部解析失败
重复/重叠分析
- base 分支已有 cgroup2 支持(PR #989),本 PR 的
/proc/[pid]/cgroup是独立 procfs 入口,不重复 - open PR #1035(eBPF JIT)、#1034(epoll)与本 PR 无重叠
- mount.rs 的 MS_REMOUNT/MS_BIND/MS_MOVE/mount propagation 已在 base 存在(PR #876, #989),本 PR 仅新增 null fs_type 处理,不重复
以下问题需要修改:
Powered by mimo-v2.5-pro
There was a problem hiding this comment.
PR #1031 复审总结
变更概述
本 PR 为 claw-code (AI coding agent) 在 StarryOS 上的运行添加内核支持:
unshare()syscall(经由namespace.rs中已有的 unshare 框架,支持CLONE_NEWUSER)/proc/self/{uid_map, gid_map, setgroups}procfs 文件(简化语义,注释已标注)/proc/[pid]/cgroupprocfs 文件- mount syscall 的 null
fs_type指针处理修复 - claw-code app 注册和测试(goal-01
05 C 测试、integration、robust-0112)
本地验证结果
cargo fmt --check: ✅ 通过cargo xtask clippy --package starry-kernel: ✅ 全部 13 个 feature check 通过,0 失败git diff --check origin/dev...HEAD: ✅ 通过cargo xtask starry test qemu --list --arch x86_64和--arch riscv64: ✅ 正确发现全部 18 个 claw-code 测试用例- 无
[patch.crates-io]覆盖
CI 状态
所有 GitHub Actions 检查均显示 skipped(fork PR 需要维护者批准后才能运行 CI)。无实际 CI 结果可作为合入依据。
前次 review 问题修复情况
与 ZR233 第一次 review (commit 355ff4d) 对比,已修复项:
- ✅ uid_map/gid_map 写入现在通过
UserNamespace.is_root接入 namespace 状态,getuid/getgid 在 is_root=false 时返回 65534 (overflow) - ✅
sys_setgroups()已检查thread.setgroups_deny(),返回 EPERM - ✅
run-local.sh已改为使用build-claw.sh源码构建,无个人 fork URL - ✅
cargo fmt --check/cargo xtask clippy全部通过
重复/重叠分析
- base 分支已有 cgroup2 支持(PR #989),本 PR 的
/proc/[pid]/cgroup是独立 procfs 入口,不重复 - mount.rs 的 MS_REMOUNT/MS_BIND/MS_MOVE/mount propagation 已在 base 存在(PR #876, #989),本 PR 仅新增 null fs_type 处理,不重复
- 当前 open PR 中无与本 PR 重叠的实现(#1080 std-aware 构建、其余 PR 均为不同功能)
实现逻辑评估
unshare(CLONE_NEWUSER)正确通过nsproxy.unshare_user()创建新 UserNamespace,is_root 初始化为 false- uid_map/gid_map 简化实现:直接设置凭证值而非维护映射表,注释已说明
- setgroups deny/allow 切换已实现,
sys_setgroups()已消费该标志 - cgroup 返回固定的
0::/,符合 cgroup v2 基本格式 - mount null fs_type 处理正确避免空指针 panic
已知限制(非阻塞)
test_framework.h在 goal-01~05 中有 5 份副本,建议后续提取为共享文件- robust 测试 timeout 较长(部分 1800s),建议后续标记为 opt-in
以下问题需要修改:
[阻塞] uid_map/gid_map 共用 UserNamespace.is_root 作为 overflow 解除标志,写入 uid_map 会影响 GID 侧可见值
当前实现中,uid_map 和 gid_map 的写入都执行 nsproxy.user_ns.lock().is_root = true。user_ns_overflow_uid() 函数检查 is_root 来决定 getuid/getgid/getresuid/getresgid 是否返回 overflow 值 65534。这意味着只写 uid_map 也会让 GID 侧退出 overflow 模式(虽然实际数值在常见场景下恰好相同——因为 unshare 后 cred.gid 已经是 65534——但语义上是错误的)。
建议将 is_root 拆分为 uid_mapped 和 gid_mapped 两个独立标志,或者明确只支持 uid_map 和 gid_map 同时配置并拒绝半配置状态。
此问题与 @ZR233 在第二次和第三次 review 中提出的阻塞项一致。
[阻塞] goal 测试缺少核心行为断言
goal-02-uid-map 和 goal-03-gid-map 仅验证 proc 文件的存在和读写成功,未在写入映射后断言 getuid()/getgid()/getresuid()/getresgid() 返回映射后的值。goal-04-setgroups 未直接调用 setgroups(2) syscall 验证写入 "deny" 后返回 EPERM。
这些断言是验证 procfs 写入是否真正接入内核语义的关键测试,缺少它们意味着测试可以通过但实际行为可能不正确。
建议补全以下测试断言:
- goal-02: unshare 后写 uid_map "0 0 1",断言
getuid() == 0且getgid()仍为 65534 - goal-03: unshare 后写 gid_map "0 0 1",断言
getgid() == 0且getuid()仍为 65534(若不修复 is_root 共享问题则此断言需要调整) - goal-04: unshare 后写 setgroups "deny",然后调用
syscall(SYS_setgroups, 0, NULL)断言返回 -1 且 errno == EPERM
此问题与 @ZR233 在第二次和第三次 review 中提出的阻塞项一致。
Powered by glm-5.1
… assertions to goal tests
… add debug output
…SimpleFile write_at semantics
There was a problem hiding this comment.
PR #1031 第十次复审 — APPROVE
变更概述
本 PR 为 claw-code (AI coding agent) 在 StarryOS 上的运行添加内核支持:
unshare()syscall,支持CLONE_NEWUSER(创建新用户命名空间),其他 namespace 标志通过 nsproxy 方法实现实际隔离/proc/self/{uid_map, gid_map, setgroups}procfs 文件,具有独立的 UID/GID 侧溢出控制/proc/[pid]/cgroupprocfs 文件,返回固定 cgroup v2 格式- mount syscall 的 null
fs_type指针处理修复 - claw-code goal-01
05 C 测试(x86_64 + riscv64)、integration 和 robust-0112 测试 - 注册 claw-code 为 StarryOS app
前次 review 问题修复情况
所有 ZR233 前次 review 提出的阻塞项在当前 HEAD 0250bf1c 中均已修复:
- ✅ uid_map/gid_map 独立溢出控制:
UserNamespace新增独立uid_mapped/gid_mapped字段,user_ns_overflow_uid()仅检查uid_mapped,user_ns_overflow_gid()仅检查gid_mapped。写入 uid_map 不影响 GID 侧,写入 gid_map 不影响 UID 侧。 - ✅ setgroups_deny 接入 sys_setgroups():
sys_setgroups()在 line 571 检查thread.setgroups_deny(),写入/proc/self/setgroups=deny后setgroups(2)返回 EPERM。 - ✅ goal-02 回归测试:写入 uid_map 后断言
getuid()==0、geteuid()==0、getresuid()==(0,0,0),同时断言getgid()==65534、getegid()==65534、getresgid()==(65534,65534,65534)未受影响。 - ✅ goal-03 回归测试:写入 gid_map 后断言
getgid()==0、getegid()==0、getresgid()==(0,0,0),同时断言getuid()==65534、geteuid()==65534、getresuid()==(65534,65534,65534)未受影响。 - ✅ goal-04 直接 syscall 断言:写入 "deny" 后直接调用
syscall(SYS_setgroups, 0, NULL)并断言 EPERM;写入 "allow" 后恢复正常。 - ✅ 无个人 fork URL:
grep -r 'MuZhao2333/tgoskits/releases'返回 0 结果。
本地验证结果
cargo fmt --check: ✅ 通过cargo clippy --manifest-path os/StarryOS/kernel/Cargo.toml --all-features -- -D warnings: ✅ 通过
CI 状态
- GitHub Actions run
26945787846为 queued 状态(fork PR 需维护者批准后才能运行 CI) - 已完成的检查:
Detect changed paths✅ success,其余 4 个容器/lint 检查为 skipped - 本地 fmt 和 clippy 已验证通过,与 CI 格式检查等价
重复/重叠分析
- base 分支已有 cgroup2 支持(PR #989),本 PR 的
/proc/[pid]/cgroup是独立 procfs 入口,不重复 - mount.rs 的 MS_REMOUNT/MS_BIND/MS_MOVE/mount propagation 已在 base 存在(PR #876, #989),本 PR 仅新增 null fs_type 处理,不重复
- 当前无重叠 open PR
实现逻辑评估
unshare():flags=0 返回成功;CLONE_NEWUSER 调用nsproxy.unshare_user()创建新的UserNamespace(is_root=false, uid_mapped=false, gid_mapped=false),溢出机制使getuid()/getgid()返回 65534;其他 namespace 标志通过nsproxy.unshare_*()实现;未知标志返回 EINVAL。符合 Linux unshare(2) 基本语义。- uid_map/gid_map:简化语义直接设置凭证,注释已明确说明;独立
uid_mapped/gid_mapped状态确保 UID/GID 侧不串扰。 - setgroups:allow/deny 切换并接入 syscall 层 EPERM 检查。
- cgroup:固定返回
0::/\n。 - mount null fs_type:避免空指针 panic。
测试覆盖评估
测试使用 syscall(SYS_...) 直接调用,避免 libc 包装掩盖 errno。测试布局正确:
- syscall 级测试在
test-suit/starryos/normal/qemu-smp1/claw-code/goal-* - app 集成场景在
apps/starry/claw-code/
已知限制(非阻塞)
test_framework.h在 goal-01~05 中有 5 份副本,建议后续提取为共享文件- robust 测试 timeout 较长(部分 1800s),建议后续标记为 opt-in
- integration/robust 测试依赖外部 claw-code 仓库编译
- CI 为 fork PR 权限限制 queued 状态,已通过本地等价验证
Powered by mimo-v2.5-pro
There was a problem hiding this comment.
PR #1031 复审 — APPROVE
变更概述
本 PR 为 claw-code 在 StarryOS 上的运行添加内核支持:
unshare()syscall,支持CLONE_NEWUSER(其他 namespace 标志为 no-op,输出 warn 日志)/proc/self/{uid_map, gid_map, setgroups}procfs 文件(简化语义,注释已标注)/proc/[pid]/cgroupprocfs 文件- mount syscall 的 null
fs_type指针处理修复 - claw-code goal-01
05 C 测试(x86_64 + riscv64)、integration 和 robust-0112 测试 - 注册 claw-code 为 StarryOS app
前次 review 问题修复情况
ZR233 最后一次 request changes 中的三条阻塞项均已修复:
- uid_map/gid_map 状态分离 ✅:
UserNamespace新增独立的uid_mapped和gid_mapped字段,user_ns_overflow_uid()仅检查uid_mapped,user_ns_overflow_gid()仅检查gid_mapped。写入 uid_map 不再影响 GID 侧可见值。 - goal-02-uid-map 测试增强 ✅:写入
"0 0 1"后断言getuid()==0、geteuid()==0、getresuid()==(0,0,0),同时断言getgid()/getegid()/getresgid()仍为 65534(未被串扰)。 - goal-04-setgroups 测试增强 ✅:写入
"deny"后直接调用syscall(SYS_setgroups, 0, NULL)并断言返回EPERM;写入"allow"后验证setgroups(2)不再返回 EPERM。 - run-local.sh 修复 ✅:改为使用
build-claw.sh源码构建,不再从个人 fork 下载预编译二进制。
本地验证结果
cargo fmt --check: ✅ 通过cargo clippy --manifest-path os/StarryOS/kernel/Cargo.toml --all-features -- -D warnings: ✅ 通过,无警告
CI 状态
- Check formatting / run_host: ✅ 成功
- Run sync-lint / run_host: ✅ 成功
- Test axvisor loongarch64 qemu / run_container: ✅ 成功
- Test axvisor self-hosted x86_64 / run_host: ✅ 成功
- Test axvisor self-hosted x86_64 UEFI / run_host: ✅ 成功
- Test starry self-hosted board licheerv-nano-sg2002 / run_host: ❌ 失败(物理板卡测试,非 PR 相关)
- 其余 QEMU 测试任务:被级联取消(由板卡测试失败触发)
板卡测试失败原因:该任务在物理 RISC-V 板卡 s1lqc-rcore-os-runner-4 上执行 cargo xtask starry test board --board licheerv-nano-sg2002,失败步骤为 "Run command"。此测试运行的是物理板卡专用的 boot 测试,与本 PR 修改的 procfs/namespace/syscall 代码和 QEMU 测试用例完全无关。该失败为基础设施/板卡状态问题。
重复/重叠分析
- base 分支已有 cgroup2 支持(PR #989),本 PR 的
/proc/[pid]/cgroup是独立 procfs 入口,不重复 - mount.rs 的 MS_REMOUNT/MS_BIND/MS_MOVE/mount propagation 已在 base 存在,本 PR 仅新增 null fs_type 处理
- 当前无重叠 open PR
实现逻辑评估
unshare()实现正确:flags=0 返回成功;CLONE_NEWUSER 通过nsproxy.unshare_user()创建新 user namespace;其他 namespace 标志接受为 no-op(本版本移除了 warn 日志,因为各标志已实际调用unshare_*方法);未知标志返回 EINVAL。- uid_map/gid_map 独立控制 overflow:写入 uid_map 设置
UserNamespace.uid_mapped=true解除 UID 侧 65534 overflow,GID 侧不受影响(反之亦然)。 setgroups实现:/proc/self/setgroups控制setgroups_deny标志,sys_setgroups()在检查CAP_SETGID之后、实际操作之前检查该标志并返回 EPERM。- cgroup 返回固定的
0::/,符合 cgroup v2 基本格式。 - mount null fs_type 处理正确避免了空指针 panic。
测试布局评估
- syscall 级测试(goal-01~05)正确放置在
test-suit/starryos/normal/qemu-smp1/claw-code/ - App 集成场景正确放置在
apps/starry/claw-code/ - 测试使用
syscall(SYS_...)直接调用而非 libc 包装,避免掩盖 errno - 测试断言全面:goal-02 同时验证 UID 侧映射和 GID 侧未串扰;goal-04 验证 deny→EPERM→allow 恢复链路
已知限制(非阻塞)
test_framework.h在 goal-01~05 中有 5 份副本,建议后续提取为共享文件- robust 测试 timeout 较长(部分 1800s),建议后续标记为 opt-in
Powered by mimo-v2.5-pro
There was a problem hiding this comment.
PR #1031 第十次复审 — APPROVE
变更概述
本 PR 为 claw-code (AI coding agent) 在 StarryOS 上的运行添加内核支持:
unshare()syscall,支持CLONE_NEWUSER(其他 namespace 标志为 no-op,输出 warn 日志)/proc/self/{uid_map, gid_map, setgroups}procfs 文件/proc/[pid]/cgroupprocfs 文件- mount syscall 的 null
fs_type指针处理修复 - claw-code goal-01
05 C 测试(x86_64 + riscv64)、integration 和 robust-0112 测试
本地验证结果
cargo fmt --check: ✅ 通过cargo clippy --manifest-path os/StarryOS/kernel/Cargo.toml --all-features -- -D warnings: ✅ 通过,无警告
前次 review 问题修复情况
ZR233 上次 review 提出的三条阻塞项在当前 HEAD 79efab0b 均已修复:
1. ✅ uid/gid map 状态分离
UserNamespace新增uid_mapped和gid_mapped独立字段sys_getgid()/sys_getegid()/sys_getresgid()改用user_ns_overflow_gid()(独立于 uid 侧)- 写 uid_map 只设置
uid_mapped=true,不影响 GID 侧 - 写 gid_map 只设置
gid_mapped=true,不影响 UID 侧
2. ✅ setgroups deny 接入 syscall
sys_setgroups()新增thread.setgroups_deny()检查,返回 EPERM- goal-04 测试直接调用
syscall(SYS_setgroups, 0, NULL)验证 EPERM
3. ✅ run-local.sh 改为源码编译
- 使用
build-claw.sh从源码构建,不再下载个人 fork 预编译二进制 - 所有 build.rs 也改为源码编译
4. ✅ 测试覆盖增强
- goal-02: 验证写 uid_map 后
getuid()返回 0,getgid()仍为 65534(无串扰) - goal-04: 验证写
setgroups=deny后setgroups(2)返回 EPERM
CI 状态
GitHub Actions 检查正在运行(state=PENDING)。已完成的检查:
- Detect changed paths: SUCCESS
- Check formatting / run_host: SUCCESS
- Run sync-lint / run_host: SUCCESS
- Test axvisor loongarch64 qemu / run_container: SUCCESS
正在运行的 QEMU 测试:starry x86_64/riscv64/loongarch64 qemu、axvisor aarch64/riscv64 qemu 等。
所有 run_container variant 因 fork PR 权限限制显示 SKIPPED,属预期行为。
目前无失败项。
重复/重叠分析
按 uid_map/gid_map/setgroups/unshare/cgroup/claw-code 和相关路径查了 base 和当前 open PR,未发现直接重复实现或明显冲突。无 [patch.crates-io] 使用。
实现逻辑评估
unshare()实现正确:flags=0 返回成功;CLONE_NEWUSER 设置所有凭证为 65534;其他 namespace 标志 no-op + warn;未知标志返回 EINVAL- uid_map/gid_map 简化实现独立控制
uid_mapped/gid_mapped,注释已明确说明简化语义 - setgroups allow/deny 正确接入
sys_setgroups()的 EPERM 路径 - cgroup 返回固定的
0::/,符合 cgroup v2 格式 - mount null fs_type 处理正确避免空指针 panic
已知限制(非阻塞)
test_framework.h在 goal-01~05 中有 5 份副本,建议后续提取为共享文件- robust 测试 timeout 较长(部分 1800s),建议后续标记为 opt-in
UserNamespace.is_root字段保留用于兼容,新代码应优先使用uid_mapped/gid_mapped
Powered by Mai reviewer agent
Powered by mimo-v2.5-pro
…es to handle all xtask flows
ZR233
left a comment
There was a problem hiding this comment.
复审当前 head 75d868ddb4bbcbeafaafe4b7a3e5dbeeb982d01b 后,前次阻塞项已经解除,我这边没有新的阻塞问题,批准。
确认点:
uid_map/gid_map已拆成独立的uid_mapped/gid_mapped状态,写 UID map 不再影响 GID 侧 overflow,可见行为也由 goal-02 / goal-03 覆盖。/proc/self/setgroups=deny已接入setgroups(2)的 EPERM 路径,goal-04 覆盖了直接 syscall 行为。- app prebuild 的 rootfs 注入路径已在当前 head 重新验证,
cargo xtask starry app qemu --arch x86_64 -t claw-code能完成 prebuild、构建并启动到交互 shell;/usr/bin/claw在 shared Alpine rootfs 和 claw-code app rootfs 中均存在且为 0755。 /proc/{1,self}/cgroup的固定0::/输出通过了新增 x86_64 QEMU 用例。
本地验证:
git diff --check origin/dev...HEADcargo fmt --checkcargo xtask clippy --package starry-kernel(13/13 checks passed)cargo xtask starry test qemu --test-group normal --arch x86_64 -c claw-code/goal-02-uid-mapcargo xtask starry test qemu --test-group normal --arch x86_64 -c claw-code/goal-03-gid-mapcargo xtask starry test qemu --test-group normal --arch x86_64 -c claw-code/goal-04-setgroupscargo xtask starry test qemu --test-group normal --arch x86_64 -c claw-code/goal-05-cgroupcargo xtask starry test qemu --test-group normal --arch x86_64 -c claw-code/integration(无CLAW_API_KEY时按预期走CLAW_SKIP)timeout 240s cargo xtask starry app qemu --arch x86_64 -t claw-code(启动到交互 shell 后由外层 timeout 结束)
重复/重叠检查按 uid_map、gid_map、setgroups、unshare、cgroup、claw-code 以及相关路径搜索了 base 和 open PR,未发现直接重复或需要阻塞合并的重叠实现。
GitHub Actions 当前 head 的完整矩阵仍在运行,已完成的 fmt / sync-lint 通过,部分 fork/container 组合按矩阵跳过;合并前仍应等待剩余 CI 结束。
There was a problem hiding this comment.
PR #1031 第九次复审 — APPROVE
变更概述
本 PR 为 claw-code (AI coding agent) 在 StarryOS 上的运行添加内核支持:
unshare()syscall,支持CLONE_NEWUSER(其他 namespace 标志为 no-op,输出 warn 日志)/proc/self/{uid_map, gid_map, setgroups}procfs 文件(简化语义,注释已标注)/proc/[pid]/cgroupprocfs 文件- mount syscall 的 null
fs_type指针处理修复 - claw-code goal-01
05 C 测试(x86_64 + riscv64)、integration 和 robust-0112 测试 - 注册 claw-code 为 StarryOS app
ZR233 上轮 review 问题修复确认
ZR233 在 6 月 4 日的两轮 review(4424055143、4425892085)中提出的核心阻塞问题,在当前 head 75d868ddb 中已全部修复:
-
uid_map/gid_map 状态隔离 ✅:
UserNamespace现在有独立的uid_mapped和gid_mapped布尔字段user_ns_overflow_uid()仅检查uid_mapped,user_ns_overflow_gid()仅检查gid_mappedclone_ns()初始化两者为false,写入时分别设置- 只写 uid_map 不影响 GID 侧可见值,反之亦然
-
goal-02-uid-map 测试断言 getuid/getresuid 变化 ✅:
- unshare 后先验证
getuid() == 65534(写入前) - 写入
"0 0 1"到 uid_map 后,断言getuid() == 0、geteuid() == 0、getresuid() == (0,0,0) - 同时断言
getgid() == 65534、getegid() == 65534、getresgid() == (65534,65534,65534)未被 uid_map 串扰
- unshare 后先验证
-
goal-03-gid-map 对称测试 ✅:
- unshare 后先验证
getgid() == 65534(写入前) - 写入 gid_map 后断言 getgid/getegid/getresgid 变为 0
- 同时断言 getuid/geteuid/getresuid 仍为 65534
- unshare 后先验证
-
goal-04-setgroups 直接调用 setgroups(2) ✅:
- 写入
"deny"后,直接syscall(SYS_setgroups, 0, NULL)并断言errno == EPERM - 写入
"allow"后,验证 setgroups(2) 不再返回 EPERM
- 写入
本地验证结果
cargo fmt --check: ✅ 通过cargo clippy --manifest-path os/StarryOS/kernel/Cargo.toml --all-features -- -D warnings: ✅ 通过,无警告git diff --check origin/dev...HEAD: ✅ 通过- 无
[patch.crates-io]覆盖 - 无个人 fork 二进制下载(build-claw.sh 从源码编译)
CI 状态
commit status 为 pending,所有 GitHub Actions check runs 显示 skipped。这是因为 fork PR 需要维护者批准后才能运行 CI,所有 skipped 均因 fork 权限限制,非本 PR 引入的失败。
重复/重叠分析
- base 分支已有 cgroup2 支持(PR #989),本 PR 的
/proc/[pid]/cgroup是独立 procfs 入口,不重复 - mount.rs 的 MS_REMOUNT/MS_BIND/MS_MOVE/mount propagation 已在 base 存在(PR #876, #989),本 PR 仅新增 null fs_type 处理,不重复
- 当前 open PRs(#886 eBPF userspace 等)与本 PR 无重叠
实现逻辑评估
unshare()实现正确:flags=0 返回成功;CLONE_NEWUSER 通过clone_ns()创建新用户命名空间,凭证重置为 65534 (nobody);其他 namespace 标志接受为 no-op 并输出 warn 日志;未知标志返回 EINVAL。符合 Linux unshare(2) 基本语义。- uid_map/gid_map 简化实现:读取返回映射格式字符串;写入解析
lower upper count格式并直接设置凭证为upper值,同时设置对应的uid_mapped/gid_mapped标志。注释已明确说明这是 StarryOS 的有意简化。 - setgroups 实现 allow/deny 切换,
sys_setgroups()中检查setgroups_deny()标志返回 EPERM,符合 Linux 3.19+ 语义。 - cgroup 返回固定的
0::/,符合 cgroup v2 基本格式。 - mount null fs_type 处理正确避免了空指针 panic。
测试覆盖评估
- syscall 级测试(goal-01~05)正确放置在
test-suit/starryos/normal/qemu-smp1/claw-code/ - App 集成场景正确放置在
apps/starry/claw-code/ - 测试使用
syscall(SYS_...)直接调用而非 libc 包装,避免掩盖 errno - 测试已覆盖 uid/gid map 的 UID/GID 侧独立性,避免了串扰回归
- setgroups 测试验证了实际 syscall 行为而非仅 proc 文件 I/O
已知限制(非阻塞)
test_framework.h在 goal-01~05 中有 5 份副本,建议后续提取为共享文件- robust 测试 timeout 较长(部分 1800s),建议后续标记为 opt-in
- integration/robust 测试依赖外部 claw-code 仓库编译,CI 环境需预装 rustup target 和 musl 工具链
Powered by mai-reviewer
Powered by mimo-v2.5-pro
There was a problem hiding this comment.
PR #1031 第九次复审 — APPROVE
变更概述
本 PR 为 claw-code (AI coding agent) 在 StarryOS 上的运行添加内核支持:
unshare()syscall,支持CLONE_NEWUSER(其他 namespace 标志为 no-op,输出 warn 日志)/proc/self/{uid_map, gid_map, setgroups}procfs 文件(简化语义,注释已标注)/proc/[pid]/cgroupprocfs 文件- mount syscall 的 null
fs_type指针处理修复 - claw-code goal-01
05 C 测试(x86_64 + riscv64)、integration 和 robust-0112 测试 - 注册 claw-code 为 StarryOS app
前次 review 问题修复情况
所有 @ZR233 提出的阻塞项均已修复:
- ✅ uid_map/gid_map 状态分离:
UserNamespace新增独立的uid_mapped和gid_mapped字段,sys.rs中user_ns_overflow_uid()和user_ns_overflow_gid()分别检查对应字段,写uid_map不会影响 GID 侧,反之亦然。 - ✅ goal-02-uid-map 回归测试:写入
0 0 1后断言getuid()==0、geteuid()==0、getresuid()==(0,0,0),同时断言getgid()/getegid()/getresgid()仍为 65534(未被 uid_map 串扰)。 - ✅ goal-04-setgroups 回归测试:写
/proc/self/setgroups=deny后直接调用syscall(SYS_setgroups, 0, NULL)断言返回 EPERM,写allow后恢复。 - ✅ sys_setgroups 检查:
sys_setgroups()新增thread.setgroups_deny()检查,deny 状态下返回OperationNotPermitted。 - ✅ 供应链风险消除:所有预编译二进制下载 URL 已移除,改为从源码编译(
build-claw.sh)。仓库中不再有MuZhao2333/tgoskits/releasesURL。 - ✅
cargo fmt --check通过 - ✅
cargo clippy --manifest-path os/StarryOS/kernel/Cargo.toml --all-features -- -D warnings通过 - ✅ 所有 TOML 配置文件解析合法
本地验证结果
cargo fmt --check: ✅ 通过cargo clippy --manifest-path os/StarryOS/kernel/Cargo.toml --all-features -- -D warnings: ✅ 通过,无警告- TOML 解析验证: ✅ 全部合法
- 供应链风险检查: ✅ 仓库中无个人 fork Release 下载 URL
CI 状态
所有 GitHub Actions 检查显示 skipped(fork PR 需要维护者批准后才能运行 CI)。一项检查 Test arceos loongarch64 qemu / run_host 仍在 in_progress。所有 skipped 检查均因 fork PR 权限限制,非本 PR 引入的失败。
重复/重叠分析
按 unshare/uid_map/gid_map/setgroups/cgroup/claw-code 以及相关路径搜索了 base 分支和当前 open PR(#1125 nix-smoke、#1124 truncate 等),未发现直接重复实现或冲突的 open PR。
实现逻辑评估
unshare()正确处理 CLONE_NEWUSER(设置凭证为 65534),其他 namespace 标志 no-op + warn,未知标志返回 EINVAL。- uid_map/gid_map 分别设置
UserNamespace.uid_mapped/gid_mapped,解除 UID/GID 侧 overflow 控制,互不干扰。 - setgroups allow/deny 语义正确,deny 后
sys_setgroups()返回 EPERM。 - cgroup 返回固定
0::/,符合 cgroup v2 基本格式。 - mount null fs_type 处理正确避免空指针 panic。
已知限制(非阻塞)
test_framework.h在 goal-01~05 中有 5 份副本,建议后续提取为共享文件- robust 测试 timeout 较长(部分 1800s),建议后续标记为 opt-in
- claw-code 源码仓库仍在贡献者个人 GitHub (
MuZhao2333/claw-code),建议后续迁移至 rcore-os 组织 UserNamespace.is_root字段保留但实际语义已被uid_mapped/gid_mapped替代,建议后续清理
Powered by Mai reviewer agent
Powered by mimo-v2.5-pro
ZR233
left a comment
There was a problem hiding this comment.
复审当前 head 8c1a006cb512 后,新增的两笔提交只调整 claw-code app 的 rootfs 锁处理路径:qemu-x86_64.toml 给 app rootfs drive 加了 file.locking=off,prebuild.sh 会删除并从 Alpine base 重新复制 rootfs-x86_64-claw-code.img 后再注入 claw,避免之前 app framework 复制出来的镜像残留锁状态。
我没有发现新的阻塞问题,批准。
本地验证:
git diff --check origin/dev...HEAD通过cargo fmt --check通过bash -n apps/starry/claw-code/prebuild.sh通过timeout 240s cargo xtask starry app qemu --arch x86_64 -t claw-code成功执行新 prebuild 流程:删除/复制 claw-code rootfs、向 Alpine 与 claw-code 两个镜像注入/usr/bin/claw,随后启动 Starry 并进入交互 shell,打印StarryOS Claw interactive shell is ready.;到达 shell 后我用 QEMU 退出序列结束运行
GitHub Actions run 26964346585 中 formatting、sync-lint、clippy、std、多个 ArceOS/Axvisor/Starry host/container job 已通过;提交 review 时仍有部分矩阵 job pending,合并前继续等完整 CI 结束即可。历史 review threads 均已 resolved,没有发现当前新增 diff 与其它 open PR 的新重叠。
There was a problem hiding this comment.
PR #1031 第九次复审 — APPROVE
变更概述
本 PR 为 claw-code (AI coding agent) 在 StarryOS 上的运行添加内核支持:
unshare()syscall,支持CLONE_NEWUSER(其他 namespace 标志为 no-op,输出 warn 日志)/proc/self/{uid_map, gid_map, setgroups}procfs 文件(简化语义,注释已标注)/proc/[pid]/cgroupprocfs 文件- mount syscall 的 null
fs_type指针处理修复 - claw-code goal-01
05 C 测试(x86_64 + riscv64)、integration 和 robust-0112 测试 - 注册 claw-code 为 StarryOS app
ZR233 前次 review 问题修复情况
本次复审确认最新 head 5afb33fec79e6fc4509cd3123402fb1d179c85fe 已修复所有阻塞项:
✅ uid_map/gid_map 串扰问题已修复:UserNamespace 现在使用独立的 uid_mapped 和 gid_mapped 字段。user_ns_overflow_uid() 检查 ns.uid_mapped,user_ns_overflow_gid() 检查 ns.gid_mapped,两者互不影响。
✅ sys_setgroups() 已检查 setgroups_deny:sys.rs:571 中 if thread.setgroups_deny() { return Err(AxError::OperationNotPermitted); } 已正确实现 EPERM 路径。
✅ 测试已包含直接 syscall 断言:
goal-02-uid-map: 写 uid_map 后断言getuid()/geteuid()/getresuid()返回 0,并验证 GID 侧不受影响goal-03-gid-map: 写 gid_map 后断言getgid()/getegid()/getresgid()返回 0,并验证 UID 侧不受影响goal-04-setgroups: 写 "deny" 后直接调用syscall(SYS_setgroups, 0, NULL)断言返回 EPERM,写 "allow" 后验证恢复
✅ cargo fmt --check: 通过
✅ cargo xtask clippy --package starry-kernel(13 个 feature 组合): 全部通过
✅ git diff --check origin/dev...HEAD: 通过
重复/重叠分析
- base 分支已有 cgroup2 支持(PR #989),本 PR 的
/proc/[pid]/cgroup是独立 procfs 入口,不重复 - 当前无重叠 open PR
CI 状态
所有 GitHub Actions check runs 显示 skipped(fork PR 需要维护者批准后才能运行 CI),非本 PR 引入的失败。
实现逻辑评估
unshare()实现正确:flags=0 返回成功;CLONE_NEWUSER 设置所有凭证为 65534 (nobody);其他 namespace 标志接受为 no-op 并输出 warn 日志;未知标志返回 EINVAL。符合 Linux unshare(2) 基本语义。- uid_map/gid_map 简化实现使用独立的
uid_mapped/gid_mapped标志,写入后正确更新凭证并设置 namespace 状态。注释已明确说明这是 StarryOS 的有意简化。 - setgroups 实现 allow/deny 切换并接入
sys_setgroups()的 EPERM 路径。 - cgroup 返回固定的
0::/,符合 cgroup v2 基本格式。 - mount null fs_type 处理正确避免了空指针 panic。
已知限制(非阻塞)
test_framework.h在 goal-01~05 中有 5 份副本,建议后续提取为共享文件- robust 测试 timeout 较长(部分 1800s),建议后续标记为 opt-in
- claw 二进制从
MuZhao2333/claw-code源码编译(非个人 fork Release 预编译二进制),安全风险已消除
Powered by Mai
Powered by mimo-v2.5-pro
ZR233
left a comment
There was a problem hiding this comment.
复审当前 head 5afb33fec79e。这个 head 相比我上次批准的 8c1a006cb512 只有一笔 chore: retrigger CI 提交,git diff --stat 8c1a006cb512..HEAD 和 git diff --name-status 8c1a006cb512..HEAD 均为空,没有代码或配置树变更。
本地快速复核:
git diff --check origin/dev...HEAD通过cargo fmt --check通过bash -n apps/starry/claw-code/prebuild.sh test-suit/starryos/normal/qemu-smp1/claw-code/build-claw.sh通过
当前 CI run 26966927346 已完成且 relevant host/container 矩阵均通过或按矩阵跳过。由于本次新 head 没有树变更,之前对 namespace/procfs/claw-code app flow 的批准结论仍然成立。
Summary
unshare()syscall,支持CLONE_NEWUSER(其他 namespace 标志为 no-op,输出 warn 日志)/proc/self/{uid_map, gid_map, setgroups}用于用户命名空间凭证配置(简化语义,注释已标注)/proc/[pid]/cgroupfs_type指针处理05 C 测试(x86_64 + riscv64)、integration 和 robustness-0112 测试CLAW_API_KEY未配置时,claw 测试自动跳过Test Plan