Skip to content

checklocks: fix TCP atomic state access - #14336

Closed
tamird wants to merge 2 commits into
google:masterfrom
tamird:checklocks-tcp-atomics
Closed

checklocks: fix TCP atomic state access#14336
tamird wants to merge 2 commits into
google:masterfrom
tamird:checklocks-tcp-atomics

Conversation

@tamird

@tamird tamird commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Two TCP state paths use atomic storage without preserving its synchronization contract.

The send-buffer option callback atomically disables autotuning without the endpoint or send-queue mutex, but endpoint probes copy the flag with RacyLoad. The first commit uses atomic snapshot accesses, declares the flag and queue-lock contracts, and extends the endpoint-probe regression with a concurrent option callback. The unsynchronized snapshot dates to 96459f5 and was retained by ef9e8d9.

Readiness and shutdown also update connection-direction bits under different mutexes. The load-then-swap added in 89b6a47 can lose a concurrent send-closed or receive-closed update. The second commit uses atomic OR and declares the field's atomic contract; passing the zero-valued open state remains a no-op.

Assisted-by: Codex

tamird added 2 commits August 22, 2026 04:58
The send-buffer option callback atomically disables autotuning without
holding the endpoint or send queue mutex. Endpoint probes copy that flag
under the queue mutex, so their RacyLoad can race with the callback.

96459f5 introduced the atomic flag alongside a non-atomic state
snapshot; ef9e8d9 preserved the race in CloneState. Load and store
the snapshot flag atomically, declare its atomic contract and the queue
lock precondition, and retain exclusive ownership of the destination.

Extend the endpoint-probe test with a concurrent option callback to
exercise the conflicting accesses through real packet processing.

Assisted-by: Codex
Readiness and shutdown can update the connection-direction cache under
different mutexes. The load followed by swap added in 89b6a47 lets
two updates read the same old value and overwrite each other, losing a
send-closed or receive-closed bit.

Use atomic OR to preserve concurrent updates and annotate the atomic
field. No caller uses the previous value, so remove the helper result.
Passing the zero-valued open state remains a no-op.

Assisted-by: Codex
@tamird

tamird commented Aug 22, 2026

Copy link
Copy Markdown
Contributor Author

r? @nybidari Could you review the send-state snapshot race and concurrent close-direction updates?

Focused local Bazel checks passed. Upstream checks have not reported yet.

cc @konstantin-s-bogom

Assisted-by: Codex

@tamird

tamird commented Aug 23, 2026

Copy link
Copy Markdown
Contributor Author

Closing in favor of consolidated #14338. 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