Skip to content

C++: Add bcopy to models and use it.#3788

Merged
MathiasVP merged 12 commits into
github:mainfrom
geoffw0:callderef
Oct 20, 2020
Merged

C++: Add bcopy to models and use it.#3788
MathiasVP merged 12 commits into
github:mainfrom
geoffw0:callderef

Conversation

@geoffw0
Copy link
Copy Markdown
Contributor

@geoffw0 geoffw0 commented Jun 24, 2020

Add bcopy to the MemcpyFunction model.

Have callDereferences use models rather than duplicating this data itself. @MathiasVP do you have any idea what Dereferences.qll's callDereferences is used for? I'd like to figure out a way to explicitly test this change.

@geoffw0 geoffw0 added the C++ label Jun 24, 2020
@geoffw0 geoffw0 requested a review from a team as a code owner June 24, 2020 18:21
@MathiasVP
Copy link
Copy Markdown
Contributor

Have callDereferences use models rather than duplicating this data itself. @MathiasVP do you have any idea what Dereferences.qll's callDereferences is used for? I'd like to figure out a way to explicitly test this change.

Not exactly sure, no. A quick search only found it being imported in semmle/code/cpp/controlflow/Dataflow.qll, where its functionality seems to be used by killedBy.

@rdmarsh2
Copy link
Copy Markdown
Contributor

Looks like the only use is in Critical/MissingNullTest.ql.

@geoffw0
Copy link
Copy Markdown
Contributor Author

geoffw0 commented Jun 25, 2020

Looks like the only use is in Critical/MissingNullTest.ql.

Ah good spot, I'd missed this use. I've added a test of MissingNullTest.ql that includes bcopy.

@geoffw0
Copy link
Copy Markdown
Contributor Author

geoffw0 commented Jul 1, 2020

It looks like there's a failing test. I will have to come back to this and investigate.

semmlecode-cpp-tests/DO_NOT_DISTRIBUTE/security-tests/CWE-119/VulnC/tests/MissingNullTest.qlref

-| bad_read2.c:36:15:36:18 | buff | Value may be null; it should be checked before dereferencing. |
 | strlen_missing_null.c:32:9:32:16 | new_buff | Value may be null; it should be checked before dereferencing. |

@adityasharad adityasharad changed the base branch from master to main August 14, 2020 18:34
@geoffw0
Copy link
Copy Markdown
Contributor Author

geoffw0 commented Oct 1, 2020

Sorry for the long delay getting back to this...

I've fixed the failing test - callDereferences still needed a special case for the varargs parameters to printf variants.

I've also modernized some code and removed the taint flow from size parameters; we don't generally consider that taint any more.

@geoffw0
Copy link
Copy Markdown
Contributor Author

geoffw0 commented Oct 14, 2020

Fixed merge conflict.

@rdmarsh2
Copy link
Copy Markdown
Contributor

Looks like localtaint.ql is failing now

@geoffw0
Copy link
Copy Markdown
Contributor Author

geoffw0 commented Oct 19, 2020

Fixed.

Comment thread cpp/ql/src/semmle/code/cpp/models/implementations/Memcpy.qll Outdated
Copy link
Copy Markdown
Contributor

@MathiasVP MathiasVP 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 MathiasVP merged commit 528afc5 into github:main Oct 20, 2020
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.

3 participants