Content-Length: 352489 | pFad | http://github.com/github/codeql/pull/19569

98 Shared/C++: Handle non-standard return values in MaD flow sources/sinks by MathiasVP · Pull Request #19569 · github/codeql · GitHub
Skip to content

Shared/C++: Handle non-standard return values in MaD flow sources/sinks #19569

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

Merged
merged 4 commits into from
May 23, 2025

Conversation

MathiasVP
Copy link
Contributor

In #19563 @jketema is adding flow sources for (among other things) GetCommandLineA which should have the following MaD specification:

["", "", False, "GetCommandLineA", "", "", "ReturnValue[*]", "local", "manual"]

(because it's not the pointer returned by GetCommandLineA that's user controlled - it's the data that's pointed to!)

However, we noticed that this is not parsed correctly by the current implementation of SourceSinkInterpretation::interpretOutput since it only has a case for getStandardReturnValueKind (and ReturnValue is the standard return value kind, not ReturnValue[*]).

This PR fixes that missing case, and I've checked that this makes the MaD specifications we want to have in #19563 work 🎉

MathiasVP added 3 commits May 23, 2025 11:16
…Output' and 'interpretInput' to handle non-standard return value input/output. This is needed to support C++'s ReturnValue[**] notation.
@Copilot Copilot AI review requested due to automatic review settings May 23, 2025 10:25
@MathiasVP MathiasVP requested a review from a team as a code owner May 23, 2025 10:25
@MathiasVP MathiasVP added the no-change-note-required This PR does not need a change note label May 23, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR extends the MaD flow specification to correctly handle non-standard return-value indirections (e.g. ReturnValue[*]) by delegating to a new getReturnValueKind helper in both the QL and C++ FlowSummary implementations.
Key changes:

  • Introduce getReturnValueKind(string) and update interpretOutput/interpretInput to use it when ReturnValue has an argument.
  • Delegate getStandardReturnValueKind() to getReturnValueKind("") in both QL and C++ modules.
  • Update model-as-data tests to expect indirect return-value flows (fix missing $ ir marks).

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
shared/dataflow/codeql/dataflow/internal/FlowSummaryImpl.qll Add getReturnValueKind, extend interpretOutput/interpretInput to handle starred return kinds.
cpp/ql/test/library-tests/dataflow/models-as-data/tests.cpp Update test expectations for indirect return-value sources.
cpp/ql/lib/semmle/code/cpp/dataflow/internal/FlowSummaryImpl.qll Route getStandardReturnValueKind() through new getReturnValueKind.

Copy link
Contributor

@jketema jketema left a comment

Choose a reason for hiding this comment

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

One small comment, otherwise LGTM. Does this need a C++ DCA experiment?

@MathiasVP
Copy link
Contributor Author

One small comment, otherwise LGTM. Does this need a C++ DCA experiment?

Thanks! Yeah, I've started a DCA run now. I don't think we have any MaD specifications that are currently affected by this, but it doesn't hurt to double check

Copy link
Contributor

@jketema jketema left a comment

Choose a reason for hiding this comment

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

LGTM.

@MathiasVP
Copy link
Contributor Author

DCA was uneventful (as expected)

@MathiasVP MathiasVP merged commit 0822ded into github:main May 23, 2025
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C++ DataFlow Library no-change-note-required This PR does not need a change note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/github/codeql/pull/19569

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy