Add a new RPC ConnectWithCreds
to allow gofer to connect to a unix domain socket with application's credentials
#11340
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.
Add a new RPC
ConnectWithCreds
to allow gofer to connect to a unix domain socket with application's credentialsDear gvisor developers,
Thank you very much for maintaining / developing gvisor!
Motivation
We had a use case (which I believe is a wide use case) that the sandboxes send requests over a unix domain socket on host, which is mapped to the container's file system and listened to by a server on the local host.
The sandboxed application is started with a prescribed uid. To authenticate the request, the server verifies the request's uid.
However, as the gofer process (which usually runs as root) executes connect(unix_domain_socket) call on behalf of the sandbox, the server always sees a uid 0. Hence the server cannot authenticate the UDS requests coming from the sandbox.
Proposal
I propose to Add a new RPC
ConnectWithCreds
to allow gofer to connect to a unix domain socket with application's credentials. On that gofer server thread, the euid/egid are temporarily changed to application's uid/gid and restored after theconnect(2)
call.Questions
What do you think of this change? Is there any security/ functionality concern? Thank you so much for your feedback!
FUTURE_COPYBARA_INTEGRATE_REVIEW=#11291 from xianzhe-databricks:fix-uds-auth c4f686f