userns: RunningInUserNS reports true inside gVisor (nsfs inode is not PROC_USER_INIT_INO)
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 65/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- go
调研方向
从 userns/userns.go 开始:阅读 runningInUserNS()、PROC_USER_INIT_INO 常量以及现有的 runningInUserNSFromUIDMap 回退逻辑(在 #255 中为 OpenVZ 添加)。改动是:在任何 inode 不匹配时都查询 uid_map,而不是只在 /proc/self/ns/user 不存在时才查询,同时保留 inode 快速路径。在 moby/sys 中运行 go test ./userns/...;完成意味着混合检查通过现有测试,并且一个 inode 为 1、带有 identity uid_map 的用例报告 false。
由索引模型根据 Issue 内容生成。
描述
Since v0.2.0 (#240), runningInUserNS() treats any /proc/self/ns/user inode other than PROC_USER_INIT_INO (0xEFFFFFFD) as being inside a user namespace. It only falls back to uid_map when /proc/self/ns/user is missing, or on OpenVZ (#255).
gVisor (runsc, checked on release-20261005.0) gives the initial user namespace's nsfs entry inode 1, and uid_map reads 0 0 4294967295. So inside any gVisor sandbox, RunningInUserNS() returns true even though the process is in the initial namespace:
$ stat -L -c %i /proc/self/ns/user
1
$ cat /proc/self/uid_map
0 0 4294967295
$ ls /proc/vz
ls: /proc/vz: No such file or directory
Impact: containerd's core/diff/apply (v2.4.2) skips its overlay fast path when RunningInUserNS() is true, and extracts every layer through a temporary overlay mount of all its lower layers. For BuildKit v0.34.2 running in a gVisor pod, unpacking a 36-layer, ~7 GB parent went from 75 s to 234 s. A single 18k-file layer took 60 s instead of 9 s.
Patching inUserNS to use runningInUserNSFromUIDMap brings unpack back to normal.
Suggestion: the hybrid check proposed in moby/moby#53592. Keep the inode fast path, but when the inode doesn't match, also consult uid_map before reporting a user namespace, rather than doing that only for OpenVZ. Virtualized procfs implementations (OpenVZ, gVisor, possibly others) don't reproduce the kernel's fixed inode.
AI disclosure: Used Claude Code + Opus 5.5 to discover and write this issue
- 主要语言
- Go
- 星标
- 104
- 派生
- 64
- 平均合并
- 2 天 4 小时
- 30 天内合并 PR
- 11
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
moby/sys 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复
-
mount: "bind" with recursive propagation (rprivate/rslave/rshared) performs a recursive bind (rbind)可能已有人在做 @f-sommerauer 于 17 天前认领。 未关闭
难度 4/5 1-2 天 新手友好度 48/100
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 74/100
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 68/100
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 35/100
维护者通常 1 天内回复
相似的 Issue
-
Sign-off cards drift between formats; write down one card format可能已有人在做 @keyxmakerx 今天认领。 未关闭documentation
难度 2/5 1-3 小时 新手友好度 65/100
keyxmakerx/Chronicle#2795 ·
维护者通常 1 天内回复
-
bug enhancement
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 2 天内回复
-
enhancement good first issue
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
refactor review: high
难度 2/5 1-3 小时 新手友好度 72/100
1lck/Lithe-IDEA#2376 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 85/100
OneBusAway/vehicle-positions#614 ·
维护者通常 1 天内回复