Skip to content

C++: Use 'FeatureEqualSourceSinkCallContext' in cpp/use-after-free and cpp/double-free #16126

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ signature module FlowFromFreeParamSig {
*/
bindingset[source, sink]
default predicate sourceSinkIsRelated(DataFlow::Node source, DataFlow::Node sink) { any() }

/**
* Gets a data flow configuration feature to add restrictions to the set of
* valid flow paths.
*/
default DataFlow::FlowFeature getAFeature() { none() }
}

/**
Expand Down Expand Up @@ -97,6 +103,8 @@ module FlowFromFree<FlowFromFreeParamSig P> {
or
n.asExpr() instanceof ArrayExpr
}

DataFlow::FlowFeature getAFeature() { result = P::getAFeature() }
}

import DataFlow::GlobalWithState<FlowFromFreeConfig>
Expand Down
4 changes: 4 additions & 0 deletions cpp/ql/src/Critical/DoubleFree.ql
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ module DoubleFreeParam implements FlowFromFreeParamSig {
predicate isExcluded = isExcludedMmFreePageFromMdl/2;

predicate sourceSinkIsRelated = defaultSourceSinkIsRelated/2;

DataFlow::FlowFeature getAFeature() {
result instanceof DataFlow::FeatureEqualSourceSinkCallContext
}
}

module DoubleFree = FlowFromFree<DoubleFreeParam>;
Expand Down
4 changes: 4 additions & 0 deletions cpp/ql/src/Critical/UseAfterFree.ql
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ module UseAfterFreeParam implements FlowFromFreeParamSig {
predicate isExcluded = isExcludedMmFreePageFromMdl/2;

predicate sourceSinkIsRelated = defaultSourceSinkIsRelated/2;

DataFlow::FlowFeature getAFeature() {
result instanceof DataFlow::FeatureEqualSourceSinkCallContext
}
}

import UseAfterFreeParam
Expand Down