Skip to content

proc: skip TID 0 when listing /proc - #15327

Merged
copybara-service[bot] merged 2 commits into
masterfrom
test/cl993932500
Oct 6, 2026
Merged

copybara-service[bot] merged 2 commits into
masterfrom
test/cl993932500

Conversation

@copybara-service

Copy link
Copy Markdown

proc: skip TID 0 when listing /proc

Summary

Skip IDOfThreadGroup == 0 in tasksInode.IterDirents so readdir(/proc) never emits a /proc/0 dirent.

IDOfThreadGroup can return 0 after deleteTask at Zombie→Dead while a directory listing is in progress. Linux has no /proc/0.

Linux Fidelity

proc_pid_readdir / next_tgid never publish tgid 0. gVisor listed the thread group after the PID mapping was already gone.

Test Plan

  • ProcTask.ProcRootNeverListsZeroTID races concurrent readdir(/proc) against reap churn.
  • Stock gVisor: listed_zero == true; failed 3/3.
  • Patched gVisor: passed 3/3. The original test scanned before waitpid and passed stock; the rewritten test is the negative control.

Made with Cursor

FUTURE_COPYBARA_INTEGRATE_REVIEW=#15011 from hugelgupf:pr/procfs-iterdirents-skip-tid0 fd2e845

IDOfThreadGroup can return 0 after deleteTask at Zombie->Dead, which made
readdir(/proc) emit a /proc/0 dirent. Linux has no such directory.

Test: ProcTask.ProcRootNeverListsZeroTID fails if "0" appears during reap
churn and passes after the skip.

Assisted-by: Cortex Code
@copybara-service copybara-service Bot added the exported Issue was exported automatically label Oct 5, 2026
@copybara-service
copybara-service Bot force-pushed the test/cl993932500 branch 3 times, most recently from ffb1f94 to e98d386 Compare October 6, 2026 03:18
@copybara-service
copybara-service Bot merged commit 131e784 into master Oct 6, 2026
1 of 3 checks passed
@copybara-service
copybara-service Bot deleted the test/cl993932500 branch October 6, 2026 04:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

exported Issue was exported automatically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants