@@ -251,7 +251,7 @@ abstract class PostUpdateNode extends InstructionNode {
251
251
* setY(&x); // a partial definition of the object `x`.
252
252
* ```
253
253
*/
254
- abstract class PartialDefinitionNode extends PostUpdateNode , TInstructionNode { }
254
+ abstract private class PartialDefinitionNode extends PostUpdateNode , TInstructionNode { }
255
255
256
256
private class ExplicitFieldStoreQualifierNode extends PartialDefinitionNode {
257
257
override ChiInstruction instr ;
@@ -264,7 +264,7 @@ private class ExplicitFieldStoreQualifierNode extends PartialDefinitionNode {
264
264
}
265
265
266
266
// There might be multiple `ChiInstructions` that has a particular instruction as
267
- // the total operand - so this definition give consistency errors in
267
+ // the total operand - so this definition gives consistency errors in
268
268
// DataFlowImplConsistency::Consistency. However, it's not clear what (if any) implications
269
269
// this consistency failure has.
270
270
override Node getPreUpdateNode ( ) { result .asInstruction ( ) = instr .getTotal ( ) }
@@ -430,9 +430,23 @@ private predicate simpleInstructionLocalFlowStep(Instruction iFrom, Instruction
430
430
// for now.
431
431
iTo .getAnOperand ( ) .( ChiTotalOperand ) .getDef ( ) = iFrom
432
432
or
433
+ // The next two rules allow flow from partial definitions in setters to succeeding loads in the caller.
434
+ // First, we add flow from write side-effects to non-conflated chi instructions through their
435
+ // partial operands. Consider the following example:
436
+ // ```
437
+ // void setX(Point* p, int new_x) {
438
+ // p->x = new_x;
439
+ // }
440
+ // ...
441
+ // setX(&p, taint());
442
+ // ```
443
+ // Here, a `WriteSideEffectInstruction` will provide a new definition for `p->x` after the call to
444
+ // `setX`, which will be melded into `p` through a chi instruction.
433
445
iTo .getAnOperand ( ) .( ChiPartialOperand ) .getDef ( ) = iFrom .( WriteSideEffectInstruction ) and
434
446
not iTo .isResultConflated ( )
435
447
or
448
+ // Next, we add flow from non-conflated chi instructions to loads (even when they are not precise).
449
+ // This ensures that loads of `p->x` gets data flow from the `WriteSideEffectInstruction` above.
436
450
exists ( ChiInstruction chi | iFrom = chi |
437
451
not chi .isResultConflated ( ) and
438
452
iTo .( LoadInstruction ) .getSourceValueOperand ( ) .getAnyDef ( ) = chi
0 commit comments