Skip to content

checklocks: synchronize exec FD-table replacement - #14294

Closed
tamird wants to merge 1 commit into
google:masterfrom
tamird:checklocks-exec-fd-table
Closed

checklocks: synchronize exec FD-table replacement#14294
tamird wants to merge 1 commit into
google:masterfrom
tamird:checklocks-exec-fd-table

Conversation

@tamird

@tamird tamird commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Exec replaces Task.fdTable without holding Task.mu, while /proc readers hold that mutex to read the pointer. Task-goroutine ownership permits unlocked reads, not writes, so the replacement races those readers.

Use UnshareFdTable to copy and publish the replacement under Task.mu. Preserve the existing CurrentMaxFDs bound and release the old table outside the mutex before removing close-on-exec descriptors. Annotate the helper's lock-exclusion precondition and make the field's asymmetric read/write contract explicit.

Assisted-by: Codex

@tamird

tamird commented Aug 22, 2026

Copy link
Copy Markdown
Contributor Author

r? @shailend-g Could you review publishing exec's replacement FD table under Task.mu?

Focused local Bazel checks passed. Upstream checks have not reported yet. The syscall integration test could not launch in the restricted local container.

Assisted-by: Codex

@github-actions
github-actions Bot requested review from nybidari and xinzhong August 22, 2026 11:44
Exec replaces Task.fdTable without holding Task.mu, while /proc readers
hold that mutex to read the pointer. Pipe-peer collection introduced by
5e247d5 also reads sibling table pointers without the mutex and can
race a sibling's unshare. Task-goroutine ownership permits unlocked
reads of the task's own pointer, not writes or other tasks' pointers.

Use UnshareFdTable to publish the exec replacement under Task.mu and
release the old table after unlocking. For pipe peers, acquire the file
references under the sibling's mutex, then collect metadata and release
the files outside it. Do not acquire another table reference: exit may
already have dropped its last reference without clearing the pointer.

Annotate the helpers' lock exclusions and document the task-goroutine
ownership alternative that checklocks cannot express. Exercise pipe-peer
collection concurrently with unshare, retaining the old table so its
destruction does not order the conflicting accesses.

Assisted-by: Codex
@tamird
tamird force-pushed the checklocks-exec-fd-table branch from ddc3c74 to 558888f Compare August 22, 2026 16:19
@tamird

tamird commented Aug 23, 2026

Copy link
Copy Markdown
Contributor Author

Closing in favor of consolidated #14343. The expanded replacement commits are prepared locally; the replacement branch has not been pushed yet.

Assisted-by: Codex

@tamird tamird closed this Aug 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant