Repository navigation
Fix Linux local mode process name matching - #340
Open
sainimal1ba-hue wants to merge 1 commit into
Open
sainimal1ba-hue wants to merge 1 commit into
sainimal1ba-hue wants to merge 1 commit into
Conversation
Process name patterns were matched against the name of the thread that creates a socket, so multithreaded applications could not be filtered unless you knew the name of the thread that opens their connections. Patterns were also truncated to 15 characters, kernel comm style. The eBPF program cannot match process names itself: the kernel only exposes the comm of the creating thread there, and bpf-linker does not support the CO-RE relocations that reading the thread group leader's comm would need. So name patterns now become marker actions in the intercept conf, and userspace resolves them to tgid sets by scanning /proc every 250 ms. The eBPF program then matches the creating task's tgid against those sets, which keeps the include and exclude ordering semantics of the other platforms. Issue: mitmproxy/mitmproxy#7931 Signed-off-by: sainimal1ba-hue <230497022+sainimal1ba-hue@users.noreply.github.com>
This branch has not been deployed
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.
Fixes #7931
Name patterns in Linux local mode were matched against the comm of the thread that creates a socket. That only works when the socket-opening thread happens to be named like the process, so multithreaded applications were impossible to filter, and patterns got cut off at 15 characters because comm is.
The eBPF program can't match process names itself: the kernel only exposes the creating thread's comm there, and bpf-linker doesn't support the CO-RE relocations we'd need to read the thread group leader's name. So name patterns now become marker actions in the intercept conf and userspace resolves them to tgid sets by scanning /proc every 250 ms, using the executable name from /proc//exe like the other platforms do (substring matching, so "fire" still matches "firefox"). The eBPF program then matches the creating task's tgid against those sets, in the same include/exclude order as the spec, so mixed specs behave like they do on the other platforms.
Pids keep their exact matching from before. New processes are picked up within one scan interval, so a process that starts and connects immediately can miss its first connections.
Tests: pattern parsing, tgid resolution against a fake process list and /proc scanning of the test process itself.
cargo test --workspace --exclude mitmproxy-linux-ebpfpasses, fmt and clippy are clean. The root test loads the new maps through the verifier, it needs sudo so it only runs in CI.