-
Notifications
You must be signed in to change notification settings - Fork 6
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
tests: add race attack tests for resolve_partial #144
Open
cyphar
wants to merge
7
commits into
openSUSE:main
Choose a base branch
from
cyphar:test-racing
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
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
cyphar
force-pushed
the
test-racing
branch
2 times, most recently
from
January 12, 2025 15:15
1257b82
to
fc44a19
Compare
If we hit a symlink like "../../../../../../../../../../foo", we skip no-op ".." components (i.e. ".." components while we are at "/") in the opath resolver. However, we forgot to pop said components from the symlink stack, which resulted in bad symlink stack errors when walking into such symlinks. Signed-off-by: Aleksa Sarai <[email protected]>
The opath resolver will return SafetyViolation if it notices a safety violation, but because openat2 just gets -EXDEV (and resolve_partial is implemented in terms of resolve) we ended up returning the safety violation as a partial resolution. In theory, returning a partial resolution is fine (since users of partial-resolutions need to be race-safe anyway) but it is preferable to avoid an attacker being able to trick libpathrs into continuing to execute after we've detected an attack. This also unifies our behaviour. In addition, remove the unused code at the end of the partial resolver (coverage analysis shows that this code is never executed and we can be fairly sure of that). Signed-off-by: Aleksa Sarai <[email protected]>
Signed-off-by: Aleksa Sarai <[email protected]>
Signed-off-by: Aleksa Sarai <[email protected]>
Signed-off-by: Aleksa Sarai <[email protected]>
The logic in the Makefile for running the tests is getting a little complicated, and we will need to add some more logic to it soon (for the racing tests as well as to deal with the new procfs-mount-blocking stuff in Linux >= 6.12) so moving it to a shell script makes a lot of sense. Signed-off-by: Aleksa Sarai <[email protected]>
These tests are mostly based on the filepath-securejoin tests, though with a few additional tests added to check for tricky symlinks. Unfortunately, because the rename exchange thread can affect any openat2 call, we cannot run these tests in parallel with other tests (otherwise you get spurrious errors because one test gets -EAGAIN too many times). So we split the rust test execution into two groups manually (nextest doesn't support natively specifying a test group as being "exclusive" in this way, unfortunately). Signed-off-by: Aleksa Sarai <[email protected]>
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.
These tests are mostly based on the filepath-securejoin tests, though
with a few additional tests added to check for tricky symlinks.
Unfortunately, because the rename exchange thread can affect any openat2
call, we cannot run these tests in parallel with other tests (otherwise
you get spurrious errors because one test gets -EAGAIN too many times).
Fixes #129
Signed-off-by: Aleksa Sarai [email protected]