Repository navigation
lanlord: read a refusal even if sending the request failed - #29
Merged
Merged
Conversation
tomhjp
approved these changes
Nov 26, 2026
tomhjp
left a comment
Member
There was a problem hiding this comment.
This works, but ideally I think it would be better to work around it on the less security sensitive side of the connection instead
| } | ||
| // Read the request before any refusal. If the server replied and | ||
| // closed before the client finished writing, the client's write could | ||
| // fail with EPIPE and it would never see the reason. |
Member
There was a problem hiding this comment.
On principle, I'd prefer to keep the server side logic as simple as possible and fix this on the client side. The initial client request write might fail if it already got closed, but it should still be able to read the server's reply
Member
Author
There was a problem hiding this comment.
(part of me says it's silly to care on a mac where they're almost never multi-user with a mix of trusted users and untrusted users, but the fix is easy enough....)
A Server may refuse a caller, by uid, before reading its request, and then replies and closes. If that close won the race with the client's write of its request, the write failed with EPIPE, and DialContext returned "sending request: write: broken pipe" without reading the reply that said why. A disallowed user would see that instead of "not allowed", and TestRefusals/uid flaked on ubuntu-latest in CI. Fix it in the Client rather than the Server, to keep the root side as simple as possible. After a failed write, read the reply anyway, since what the server wrote before closing is still readable, and report the write error only if there is no reply. A write that failed because of the context still returns the context's error at once. go test -count=3000 -cpu=1,2,4 -run TestRefusals/uid reproduced the failure before. With this, it passes, including runs where the write got EPIPE. Updates tailscale/corp#51929 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com> Change-Id: I17ffa4ec13b068ce572b060f7bac2e01afe29921
bradfitz
force-pushed
the
bradfitz/lanlord-flake
branch
from
November 26, 2026 21:20
995731a to
eb36f3c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A Server may refuse a caller, by uid, before reading its request, and
then replies and closes. If that close won the race with the client's
write of its request, the write failed with EPIPE, and DialContext
returned "sending request: write: broken pipe" without reading the
reply that said why. A disallowed user would see that instead of "not
allowed", and TestRefusals/uid flaked on ubuntu-latest in CI.
Fix it in the Client rather than the Server, to keep the root side as
simple as possible. After a failed write, read the reply anyway, since
what the server wrote before closing is still readable, and report the
write error only if there is no reply. A write that failed because of
the context still returns the context's error at once.
go test -count=3000 -cpu=1,2,4 -run TestRefusals/uid reproduced the
failure before. With this, it passes, including runs where the write
got EPIPE.
Updates tailscale/corp#51929