-
-
Notifications
You must be signed in to change notification settings - Fork 533
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
Unknown process connections due to missing /proc/pid/task parsing #343
Comments
@AlexFromChaos, there is no compelling reason not to do it. We will probably not lose more than 5 milliseconds by parsing those. |
oops, I misread, it says "of every PID", meaning every PID on the machine. Yeah, that can run up into 100s of ms. |
Granted, we can optimize it to first lookup in the most-recent-used processes' /proc entries, though. |
I don't know now because we've optimized many aspects of that part of the code, but when I wrote that comment the parsing time was prohibitive. |
hmm, maybe it won't be so bad considering PID cache. |
@AlexFromChaos , yes, thanks, give it a shot. |
it would be interesting to have some way of enabling experimental features, like intercepting incoming connections (#283 ). |
Looks like it could be something more than threads with their own (unshared) |
assumptions: conclusion: ask: doubt: ps: |
Threads can have their own descriptor table, either upon creation or later during lifetime via the
I did some brief stracing when it happens and for now can tell that the process which creates such connection doesn't quit - PID remains same and some other network activity continues after the connection. Looks like it happens with async sockets only, so quick socket close is an obvious rootcause candidate. I'll try to debug this issue more to understand the exact reason.
It happens randomly while browsing some heavy sites (eg. YouTube), IP-addresses for those unknown connections are normally some subdomains of visited sites, the port is https typically. |
I'm debugging this issue, and besides the problem of not intercepting connections of a task, I'm quite sure that there's a bug in the code or some network oddity. It's easily reproducible using gnome-maps, and zooming in and out the map continously. In this case, all the connections are opened by the pid 8849, but sometimes the inode is not present under This was the missed connection:
right after getting the inode from the kernel, I refreshed and dumped the file descriptors/sockets from enabling the kprobe
so there's a mystery yet to be revealed. |
well, the usual order of states is: new syn -> however when we queried the kernel for the connection it dumped the entry with the state |
many of the "unknown connections" that I used to have are know gone by using new monitor method eBPF. |
Probably the most common reason why inode is not present in PID's
So it created an From this list of polled fds |
good analysis alex! That's what we saw a while back: gustavo-iniguez-goya#84 (comment) gustavo-iniguez-goya#10 (comment) I created a tester to test this case, and now with kprobes we intercept it. However I still see some random missing connections from chrome (although a lot less). I don't know if it'll be related to have it jailed/containerized, besides what you said. I'll keep an eye on all of this to keep improving it. |
hmm, I think in theory it should be possible to use ftrace infrastructure to monitor This will allow to keep a consistent mapping between PIDs and socket fds (likely even to get inode at the first place), removing dead entries on |
This problem should be fixed with version v1.4.0 and eBPF as process monitor method. |
Currently in some situations (like multi-process Firefox/Chrome instances) OpenSnitch fails to determine process' PID from inode as the connection originating from a child process, whose PID entry is at
/proc/<parent_PID>/task/<PID>
, not/proc/<PID>
.Because of this, per-process rules cannot be applied to many connections from apps like Firefox/Chrome.
Is there some legitimate reason why we can't do
/proc/pid/task
parsing?The comment in code says:
The question is, does it slow down things so badly? Perhaps allowing user to manually enable it via settings might be a good solution if so.
The text was updated successfully, but these errors were encountered: