-
Notifications
You must be signed in to change notification settings - Fork 1.7k
C++: data flow through partial chi operands where type is known #2676
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
Conversation
This allows adding a multi-line case without the auto-formatting changes becoming too disruptive.
af8bbf4
to
7376daf
Compare
The result type of the |
Won't stack-allocated structs normally be their own virtual variable? That makes this seem much more common to me. |
Then a write to a field of a struct will cause data flow to the whole struct? That doesn't seem great. On the other hand, it's exactly what I'm trying to achieve for For data flow, perhaps we could require that the size of the partial operand equals the size of the chi result? I'm hoping that would support common cases of |
Conflicts: cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll cpp/ql/test/library-tests/dataflow/DefaultTaintTracking/tainted.expected
I've fixed merge conflicts and taken this PR out of draft state. There's still the open question of whether the flow should be data flow, taint flow, or maybe sometimes one and sometimes the other. I don't think that matters for the January deadline, though. |
It turns out this PR doesn't go far enough to include everything we'll need after #2696. See https://github.slack.com/archives/CP0LHP150/p1580312043150500. |
This changes the flow to be taint rather than data flow, and it extends it to include chi instructions with unknown type as long as they're not for the `AliasedVirtualVariable`. We're losing three good test results because these tests are not affected by `DefaultTaintTracking.qll`. The taint step added here can later be ported to `TaintTrackingUtil.qll` to recover these results, but we probably want a better API than transitive-closure search through instructions before doing that.
Solution pushed. |
The last commit, 52d2beb, had no effect on the security qltests. |
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.
Looks good to me for now. We'll need to come back to where it fits in the core dataflow library
This PR builds on top of #2667 and #2657, so I've initially opened it as a draft. The main change is in af8bbf4. As evidenced by the diffs, these changes together enable IR data flow through the most common case of definition by reference.
I've attempted to distinguish the unhelpful (for data flow) chi instructions from the helpful ones based on their result type. I thought originally that we'd need to thread some new predicates through the SSA construction, but the type-based approach seems to work. Maybe @rdmarsh2 or @dbartol can point out a case where it won't work.