-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[tsan] Lazily call 'personality' to minimize sandbox violations #79334
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably could test this by defining own personality function in a test that will simply abort. This way we can have a list of functions that must not be called by the runtime (prohibited by sandboxes).
Though my bet is that it will fail on some platforms for some reasons. So probably the test should be limited to Linux/x86 only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not quite sure how I could add this to the TSan tests, since the sandbox behavior (e.g., allowing/disallowing 'personality') is dependent on the vendor's configuration.
Taken to an extreme, there's probably some sandbox out there that disallows 'printf', but it would be unreasonable to avoid printf entirely in TSan.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant adding this to a test:
Such test should abort w/o this fix.
Probably better to add to sanitizer_common tests so that all sanitizers are tested.
Of course, there can be sandboxes that prohibit too much and sanitizers won't work under these sandboxes. We can't fix that. But we do want to avoid personality and we want it to not regress tomorrow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see! I've added
compiler-rt/test/sanitizer_common/TestCases/Linux/sandbox_forbidden_functions.cpp
. I tested that the test failed with TSan in the absence of this fix, and passes with this fix.Note that it does have a false positive when TSan is run with high-entropy ASLR: in that environment, calling 'personality' (to check/disable ASLR) is the intended behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will it be flaky on bots then? That's not good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will be flaky on bots that have very high-entropy ASLR. AFAIK there are currently no such bots (because without the re-exec patch, all TSan tests would be failing consistently on those bots).
With that caveat in mind, please let me know if you would prefer to not test 'personality'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it would be only about bots, then I would say let's try to add it (perhaps with an additional comment).
But it will also fail on local developer
ninja check-sanitizer
runs, right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will fail on local developer
ninja check-sanitizer
if they are running with very high entropy ASLR.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then I afraid it's probably better to disable the test.
But also work under that sandbox will probably break soon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've removed the test in the latest commit (0b4c846).
With the re-exec patch + this patch: