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
Make sure to extract absolute file paths on exec #166
Merged
Merged
Conversation
This file contains 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
MatteoNardi
commented
Mar 24, 2023
MatteoNardi
force-pushed
the
fix_relative_exec
branch
from
March 31, 2023 09:45
8ebdeef
to
95348e4
Compare
misc(bpf): cleanup get_path
Tests were failing because we were searching in rules maps (target and whitelist map) an image which contained potential garbage after the filename.
On busybox-based embedded systems, `which echo` returns `/bin/echo`, which is a symlink to `/bin/busybox`. On relative path execution, our `sched_process_exec` handler takes the path from `bprm->filename`, which leads to the linked at file. For this reason we need to use `canonicalize()` in the relative exec test case.
The LOOP macro now takes an extra `max_unroll` parameter, which defines the maximum loop unroll when bpf_loop is missing. This allows in `get_path_str` to have a MAX_PATH_COMPONENTS of 100, but unroll the loop only up to 20, since a bigger value would be rejected by the verifier.
MatteoNardi
force-pushed
the
fix_relative_exec
branch
from
April 5, 2023 16:00
7097fd5
to
6dc496e
Compare
banditopazzo
requested changes
Apr 18, 2023
banditopazzo
approved these changes
Apr 18, 2023
3 tasks
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.
Fix process-monitor to always get the absolute file path on exec.
Before this change executing a file with a relative path would have resulted in an exec event with path
./executable
. After this change it will be/path/to/executable
.Since the code to extract the full file path is quite complex, we'll execute it only when needed.
I have
cargo fmt
;cargo clippy
;cargo test
and all tests pass;