Skip to content
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

DataFlow: Support stateless isSink in StateConfigSigs #13851

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

MathiasVP
Copy link
Contributor

@MathiasVP MathiasVP commented Jul 31, 2023

Sometimes it's necessary to have a state-based configuration to define the correct isBarrier, but if data then does manage to reach a sink, any state should be accepted. Prior to this PR, the only way to prevent a cartesian product would be to do something like:

module PruningConfig implements ConfigSig {
  predicate isSource(Node source) {
    exists(MyState state | isSourceImpl(source, state))
  }

  predicate isSink(Node sink) { ... }
}

module PruningFlow = Global<PruningConfig>;

FlowState viableStateForSink(Node sink) {
  exists(PruningFlow::PathNode pSource, PruningFlow::PathNode pSink |
    PruningFlow::flowPath(pSource, pSink) and
    pSink.getNode() = sink and
    isSourceImpl(pSource.getNode(), result)
  )
}

module RealConfig implements StateConfigSig {
  class FlowState = MyState

  predicate isSource(Node source, FlowState state) { isSourceImpl(source, state) }

  predicate isSink(Node sink, FlowState state) {
    ... and state = viableStateForSink(sink) // <-- to prevent CP with all flow states.
  }

  predicate isBarrier(Node barrier, FlowState state) { ... }
}

because there was no isSink/1 on StateConfigSig. With this PR we can now do:

module RealConfig implements StateConfigSig {
  predicate isSource(Node source, FlowState state) { ... }

  predicate isSink(Node sink) { ... }

  predicate isBarrier(Node barrier, FlowState state) { ... }
}

with no PruningFlow mess.

cc @aschackmull I hope this isn't too controversial?

Copy link
Contributor

@aschackmull aschackmull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is going to need some changes.

@MathiasVP
Copy link
Contributor Author

@aschackmull I've rebased the PR now that #13863 has been merged (🎉).

@MathiasVP MathiasVP marked this pull request as ready for review August 2, 2023 12:41
@MathiasVP MathiasVP requested review from a team as code owners August 2, 2023 12:41
@MathiasVP MathiasVP requested review from a team as code owners August 2, 2023 12:41
@MathiasVP
Copy link
Contributor Author

MathiasVP commented Aug 2, 2023

Hmmm @aschackmull I think adding the additional conjuncts to sinkNode breaks in the use of sinkNode in the partial flow case 😭. I've implemented one possible fix in 50f5c4d.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants