userns: RunningInUserNS reports true inside gVisor (nsfs inode is not PROC_USER_INIT_INO)

Đang mở Phù hợp với người mới
#285 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
65/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
go
Lĩnh vực
operating-systems

Hướng nghiên cứu

Bắt đầu trong userns/userns.go: đọc runningInUserNS(), hằng số PROC_USER_INIT_INO và fallback runningInUserNSFromUIDMap hiện có (được thêm cho OpenVZ trong #255). Thay đổi là tra cứu uid_map khi có bất kỳ sự không khớp inode nào thay vì chỉ khi /proc/self/ns/user vắng mặt, đồng thời giữ nguyên fast path của inode. Chạy go test ./userns/... trong moby/sys; hoàn tất nghĩa là kiểm tra hybrid vượt qua các test hiện có và một trường hợp inode là 1 với uid_map identity báo false.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
Go
Star
104
Fork
64
Merge trung bình
2 ngày 4 giờ
Pull request đã merge (30 ngày)
11

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của moby/sys

Tất cả issue của moby/sys

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.