Skip to content

proc: return ESRCH for /proc/<pid>/stat of a reaped task - #15247

Open
copybara-service[bot] wants to merge 1 commit into
masterfrom
test/cl992613446
Open

copybara-service[bot] wants to merge 1 commit into
masterfrom
test/cl992613446

Conversation

@copybara-service

Copy link
Copy Markdown

proc: return ESRCH for /proc//stat of a reaped task

Summary

If IDOfTask is 0 while generating /proc/<pid>/stat, return ESRCH instead of printing pid 0.

Holding the file open across waitpid races Generate() with deleteTask: after Zombie→Dead, IDOfTask returns 0 and stock gVisor emitted 0 (comm) .... Linux returns ESRCH once the task is gone.

Linux Fidelity

proc_tgid_stat / do_task_stat fail with -ESRCH when the task cannot be found. Printing tgid 0 is not a Linux result.

Test Plan

  • ProcPidStatTest.ReapedTaskNeverReportsPIDZero holds /proc/<pid>/stat open across reap.
  • Stock gVisor: reads start with "0 "; failed 3/3.
  • Patched gVisor: passed 3/3 (ESRCH/ENOENT or a real pid).

Made with Cursor

FUTURE_COPYBARA_INTEGRATE_REVIEW=#15012 from hugelgupf:pr/procstat-reaped-esrch b0db366

@copybara-service copybara-service Bot added the exported Issue was exported automatically label Oct 3, 2026
@copybara-service
copybara-service Bot force-pushed the test/cl992613446 branch 3 times, most recently from c4e1a88 to 8ad8f09 Compare October 6, 2026 00:20
## Summary
If `IDOfTask` is 0 while generating `/proc/<pid>/stat`, return ESRCH instead of printing pid 0.

Holding the file open across `waitpid` races `Generate()` with `deleteTask`: after Zombie→Dead, `IDOfTask` returns 0 and stock gVisor emitted `0 (comm) ...`. Linux returns ESRCH once the task is gone.

## Linux Fidelity
`proc_tgid_stat` / `do_task_stat` fail with `-ESRCH` when the task cannot be found. Printing tgid 0 is not a Linux result.

## Test Plan
- `ProcPidStatTest.ReapedTaskNeverReportsPIDZero` holds `/proc/<pid>/stat` open across reap.
- Stock gVisor: reads start with `"0 "`; failed 3/3.
- Patched gVisor: passed 3/3 (ESRCH/ENOENT or a real pid).

Made with [Cursor](https://cursor.com)

FUTURE_COPYBARA_INTEGRATE_REVIEW=#15012 from hugelgupf:pr/procstat-reaped-esrch b0db366
PiperOrigin-RevId: 992613446
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.

1 participant