Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ensure connections from /proc/net/tcp{,6} get the right pid #2639

Merged
merged 1 commit into from
Jun 26, 2017

Conversation

rade
Copy link
Member

@rade rade commented Jun 24, 2017

ProcNet.Next does not allocate Connection structs, for efficiency. Instead it always returns a *Connection pointing to the same instance. As a result, any mutations by the caller to struct elements that aren't actually set by ProcNet.Next, in particular Connection.Proc, are carried across to subsequent calls.

This had hilarious consequences: connections referencing an inode which we hadn't come across during proc walking would be associated with the process corresponding to the last successfully looked up inode.

The fix is to clear out the garbage left over from previous calls.

Fixes #2638.

@rade rade requested a review from 2opremio June 24, 2017 17:30
@rade rade force-pushed the 2638-connection-pid-pollution branch from ec8d7fc to c29974f Compare June 24, 2017 17:31
@rade
Copy link
Member Author

rade commented Jun 24, 2017

Note that with this change, the troublesome connection from #2638 doesn't show up at all, which arguably is the correct outcome, given that one of the connection ends belongs to a short-lived process that has since vanished.

@rade
Copy link
Member Author

rade commented Jun 24, 2017

tests are failing because of #2640.

ProcNet.Next does not allocate Connection structs, for efficiency.
Instead it always returns a *Connection pointing to the same instance.
As a result, any mutations by the caller to struct elements that
aren't actually set by ProcNet.Next, in particular Connection.Proc,
are carried across to subsequent calls.

This had hilarious consequences: connections referencing an inode
which we hadn't come across during proc walking would be associated
with the process corresponding to the last successfully looked up
inode.

The fix is to clear out the garbage left over from previous calls.

Fixes #2638.
@rade rade force-pushed the 2638-connection-pid-pollution branch from c29974f to 30e0444 Compare June 25, 2017 10:00
@2opremio
Copy link
Contributor

Really good catch

@rade rade merged commit 80790e4 into master Jun 26, 2017
@rade rade deleted the 2638-connection-pid-pollution branch July 5, 2017 13:07
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.

connection to dead process associated with different process
2 participants