-
Notifications
You must be signed in to change notification settings - Fork 84
Improve memset analysis
#696
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
Conversation
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
|
On top of #695 (comment), this doesn't seem to help much either: Summary for all memory locations:
- safe: 2001
- vulnerable: 181
- unsafe: 863
- -------------------
- total: 3045
+ safe: 1736
+ vulnerable: 68
+ unsafe: 870
+ -------------------
+ total: 2674Also, this seemed to increase the analysis time from ~40min to ~48min. Still, the |
michael-schwarz
approved these changes
Apr 26, 2022
…access partitioning That partitioning was unsound for alloc variables (with void type in some cases), so had to be disabled to trade precision for soundness.
sim642
added a commit
that referenced
this pull request
Apr 27, 2022
Should fix 04-mutex/70-memset_indirect_nr on MacOS CI.
sim642
added a commit
that referenced
this pull request
Apr 27, 2022
Should fix 01-cpa/24-library_functions on MacOS CI.
This was referenced Apr 27, 2022
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.
This contains additional attempts to improve race detection precision on zstd after the soundness fixes.
I noticed that certain
memsetcalls are accessing an unreasonably large number of memory locations and causing write races there. As a special function, the access analysis calculates the set of reachable addresses from its argument(s) and emits writes to all of them. Notably, if a memset struct contains a pointer to something else (another struct), then a write to the latter is also added. But this is unnecessarily imprecise, becausememsetonly changes/writes what it immediately points to and doesn't dereference any pointers inside. In general special functions may do that, butmemset(and probably many others) don't as generic functions, so instead of reachable addresses it suffices to just emit accesses to may point to addresses (i.e. not go transitive).Additionally, I tried to fix #691, i.e. add explicit
memsethandling to base analysis as well. My hope is that this avoids introducing at least some unknown pointers whose calls later cause spurious races.Changes
memset. This is very ad-hoc for the time being. Ideally each invalidation argument would also specify whether it may access transitively or not.free#695 because a similar (but not the same) issue appears here (no alloc variables in the failing test). Instead, the access analysis incorrectly calculates the type of thememsetargument asvoidbecause it's implicitly cast tovoid*by CIL formemset. Considering how stupidly the type-partitioning fails, I have serious doubts about fixing it.memsethandling in base analysis to write a zero value of the corresponding type ifmemsetargument is 0 (closes Zero-initialization usingmemset#691).memsetprecision on non-zero arguments as well by avoiding all reachable invalidation.TODO
__builtin_memsethandling as well, because zstd's macro calls it directly.freeinstead of Add option for ignoring races fromfree#695?