Sitelet https://web.archive.org/web/20260110161417/https://github.com/github/codeql/pull/11743
Skip to content

Conversation

@MathiasVP
Copy link
Contributor

@MathiasVP MathiasVP commented Dec 19, 2022 •

Previously, we failed to identify that flow can come out of functions with a signature like readv. This PR fixes this.

Slightly more generally, this PR fixes problems related to getting flow out of a function like:

void foo(const char** p);

since it's perfectly possible for foo to write to *p.

Luckily, everything in dataflow was already setup to handle the flow. We just didn't didn't add dataflow nodes representing the outgoing flow for such arguments.

There are a lot of new results (and no lost results 🎉!). I've checked all the SAMATE once, and they all seem to be in tests that we're expected to flag. Similarly, the results on real code also look like things the queries are expected to find (but which we didn't find previously because we had assumed flow couldn't exit through some const parameter).

@github-actions github-actions bot added the C++ label Dec 19, 2022
@MathiasVP MathiasVP changed the title C++: PostUpdateNodes for pointer-to-const arguments C++: PostUpdateNodes for <s>pointer-to-const</s>const-pointer arguments Dec 20, 2022
@MathiasVP MathiasVP force-pushed the fix-pointer-to-const-nodes branch 3 times, most recently from dec0d85 to 76cd5cc Compare January 10, 2023 17:31
@MathiasVP MathiasVP changed the title C++: PostUpdateNodes for <s>pointer-to-const</s>const-pointer arguments C++: PostUpdateNodes for const-pointer arguments Jan 10, 2023
@MathiasVP MathiasVP marked this pull request as ready for review January 10, 2023 17:35
@MathiasVP MathiasVP requested a review from a team as a code owner January 10, 2023 17:35
@MathiasVP MathiasVP added the no-change-note-required This PR does not need a change note label Jan 11, 2023
@MathiasVP
Copy link
Contributor Author

MathiasVP commented Jan 11, 2023 •

Bahh... Looks like there are some bad result changes to the NonConstantFormat query that I need to investigate. So I'll convert this PR back to a draft 😭.

Edit: Fixed!

@MathiasVP MathiasVP marked this pull request as draft January 11, 2023 09:38
@MathiasVP MathiasVP force-pushed the fix-pointer-to-const-nodes branch from 76cd5cc to 3571341 Compare January 11, 2023 13:40
@MathiasVP MathiasVP force-pushed the fix-pointer-to-const-nodes branch from 3571341 to cc03716 Compare January 11, 2023 16:26
@MathiasVP MathiasVP marked this pull request as ready for review January 11, 2023 21:29
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.

Mostly looks plausible. One question.

exists(PointerWrapper pw, Type t |
cppType.hasType(t, _) and
t.stripType() = pw and
not pw.pointsToConst()
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason we do not have to drill into the type being wrapped here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nah. This was really just me trying to minimize the amount of code I touched in a single PR 😂. I think a similar careful type inspection could be done for smart pointers (which is mostly what a PointerWrapper type is).

Copy link
Contributor

Choose a reason for hiding this comment

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

Should we keep track of this somehow?

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean: issue, comment, ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, good point. I'll create an issue for it 👍.

…mmon.qll

Co-authored-by: Jeroen Ketema <93738568+jketema@users.noreply.github.com>
@MathiasVP
Copy link
Contributor Author

I'm merging this since the CI failures aren't caused by this PR (it seems to happen on all PRs currently 😭).

@MathiasVP MathiasVP merged commit 2aace0d into github:mathiasvp/replace-ast-with-ir-use-usedataflow Jan 13, 2023
@jketema
Copy link
Contributor

jketema commented Jan 13, 2023

I'm merging this since the CI failures aren't caused by this PR

That's fine, It was ok before, and we only changed one comment.

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

Labels

C++ 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