C++: Remove more field-to-object flow#5327
Merged
jbj merged 7 commits intogithub:mainfrom Mar 5, 2021
Merged
Conversation
rdmarsh2
reviewed
Mar 4, 2021
| } | ||
|
|
||
| /** | ||
| * Holds if the `ChiPartialOperand` totally, but not exactly, overlaps with the `ChiTotalOperand`. |
Contributor
There was a problem hiding this comment.
This should be "partially overlaps with", I believe. A "total" overlap overwrites all bits but could be a larger write or with a different type, an "exact" overlap writes with the same type and overwrites all bits.
Contributor
Author
…esLocation when Alias::getEndBitOffset doesn't have known value.
Contributor
Author
|
I forgot to link to the CPP-differences results. Here they are in case we need to look at them again later. |
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.
Copy/paste from my comment here:
While looking through the CPP-differences changes for #3364 I found another source of field -> object taint in
simpleInstructionLocalFlowStepinDataFlowUtil:This rule ensures that we get flow from the
WriteSideEffectafter callingset_valueto the argument tosinkin this example:however, it also transfers flow from the
WriteSideEffectto thesinkargument in the following case:this pattern gave rise to some field conflation on
cpp/uncontrolled-allocation-sizeon OpenJDK and oncpp/unbounded-writeon vim.The fix is to restrict the rule in
simpleInstructionLocalFlowStepto only propagate flow from theWriteSideEffectto theChiwhen we know that theChiisn't only a partial update.We should be able to use thegetUpdatedIntervalpredicate on theChiInstructionfor this.I was right about everything except for the very last line. It's not so easy to use
getUpdatedIntervalto detect whether the entire memory location is updated since (AFAIK) it's not possible to get the type of the memory location without digging into SSA. So I added a new predicate onChiInstructionthat forwards to a new predicate inSSAConstruction.qllwhich then does the actual work.Unfortunately, we lose a couple of results in dataflow. This is due to field flow not looking "deep enough" through the destination address on write side effects (i.e., we only look check whether the destination instruction is a
FieldAddressor not, but we should traverse through the entire chain of instructions like in #5127). SosimpleInstructionLocalFlowStepexpects field flow to handle this case, but it currently doesn't.@dbartol / @rdmarsh2 I'd appreciate your thoughts on the first commit (i.e. 200d947).
(Part of https://github.com/github/codeql-c-analysis-team/issues/103.)