Repository navigation
feat(ssh-agent): pin the peer process with a pidfd before reading /proc - #156
Merged
Merged
Conversation
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.
Refs #61
nodkey ssh-agentreads the claimed context of an SSH login from/proc/<pid>. If ssh ended and its process ID went to a new process, the open of/proc/<pid>could land on the new process. A parent's ID could be used again the same way.What changes
SO_PEERPIDFD, Linux 6.5 and newer). After it opens/proc/<pid>, it checks with the pidfd that the process still runs (pidfd_send_signalwith signal 0). If not, the sign request goes without the command lines and the reason.SO_PEERPIDFDbut gives no pidfd (for example the process already ended), the request also goes without them.SO_PEERPIDFDthe agent works as before (with the parent check).Choices
pidfd_send_signalinstead ofPIDFD_GET_INFO: it works on every kernel that hasSO_PEERPIDFD(6.5), and it is one syscall.golang.org/x/sys/unix: no new direct dependency. They are the same on amd64 and arm64, the only release targets.Progress
TestPeerExitedBeforeRead,TestClaimedContextNotRunning,TestClaimedContextParentChanged).