C++: Improve hasUpperBoundsCheck#3062
Merged
Merged
Conversation
jbj
previously approved these changes
Mar 16, 2020
jbj
left a comment
Contributor
There was a problem hiding this comment.
I'm happy with this, but the qlformat check is failing.
| @@ -139,10 +149,10 @@ private predicate writesVariable(StoreInstruction store, Variable var) { | |||
| // previously suppressed by this predicate by coincidence. | |||
| private predicate hasUpperBoundsCheck(Variable var) { | |||
| exists(RelationalOperation oper, VariableAccess access | | |||
Contributor
There was a problem hiding this comment.
Would you go so far as to change RelationalOperation to ComparisonOperation? I think we've seen some code recently that took a size from the network, verified that it was equal to some constant, and then allocated that size of memory.
It doesn't have to be in this PR.
Contributor
Author
There was a problem hiding this comment.
I'll look into this as a follow-up (I think I remember seeing that code).
jbj
approved these changes
Apr 7, 2020
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.
Change
hasUpperBoundsCheckso that more kinds of bounds are accepted, leading to fewer false positives from TaintedAllocationSize.ql (see #2762 and #3016). There are still some accuracy issues around the 'multiplication by a sizeof' part of this query, but I'm not happy with my solution to that yet, so further changes will come as a follow-up.Note that in the long run we intend to replace
hasUpperBoundsCheckwith a more robust mechanism (at the moment for example, we don't care where the upper bounds check occurs, it might occur after the allocation has been made).