-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Brodes/seh flow phase1 throwing models #18014
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
Changes from 6 commits
de05aee
4b83a45
1c7b5ae
792231c
1c874d3
5bb765d
26d590a
63ddd81
0784776
ae1ed38
a69daa0
23485f1
4e77756
69df07e
6aa7412
9b2590e
4412691
7059fc3
248f1c4
583651b
66cf736
37365c7
e6641e7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| --- | ||
| category: minorAnalysis | ||
| --- | ||
| * Removed NonThrowing.qll. Throwing meta-data now part of Throwing.qll. Updated models and IR to use the new Throwing library and predicates. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,13 +3,13 @@ | |
| * functions. See `semmle.code.cpp.models.Models` for usage information. | ||
| */ | ||
|
|
||
| import semmle.code.cpp.Function | ||
Check warningCode scanning / CodeQL Redundant import Warning
Redundant import, the module is already imported inside
semmle.code.cpp.models.interfaces.ArrayFunction Error loading related location Loading Redundant import, the module is already imported inside semmle.code.cpp.models.interfaces.DataFlow Error loading related location Loading Redundant import, the module is already imported inside semmle.code.cpp.models.interfaces.Alias Error loading related location Loading Redundant import, the module is already imported inside semmle.code.cpp.models.interfaces.SideEffect Error loading related location Loading Redundant import, the module is already imported inside semmle.code.cpp.models.interfaces.Taint Error loading related location Loading Redundant import, the module is already imported inside semmle.code.cpp.models.interfaces.NonThrowing Error loading related location Loading |
||
| import semmle.code.cpp.models.interfaces.ArrayFunction | ||
| import semmle.code.cpp.models.interfaces.DataFlow | ||
| import semmle.code.cpp.models.interfaces.Alias | ||
| import semmle.code.cpp.models.interfaces.SideEffect | ||
| import semmle.code.cpp.models.interfaces.Taint | ||
| import semmle.code.cpp.models.interfaces.NonThrowing | ||
| import semmle.code.cpp.models.interfaces.Throwing | ||
|
|
||
| /** | ||
| * The standard functions `memcpy`, `memmove` and `bcopy`; and the gcc variant | ||
|
|
@@ -106,6 +106,8 @@ | |
| not this.hasGlobalName(["bcopy", mempcpy(), "memccpy"]) and | ||
| index = this.getParamDest() | ||
| } | ||
|
|
||
| override TCxxException getExceptionType() { any() } | ||
|
||
| } | ||
|
|
||
| private string mempcpy() { result = ["mempcpy", "wmempcpy"] } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,11 @@ | ||
| import semmle.code.cpp.models.interfaces.Throwing | ||
|
|
||
| class WindowsDriverFunction extends ThrowingFunction { | ||
| WindowsDriverFunction() { | ||
| class WindowsDriverExceptionAnnotation extends ThrowingFunction { | ||
| WindowsDriverExceptionAnnotation() { | ||
| this.hasGlobalName(["RaiseException", "ExRaiseAccessViolation", "ExRaiseDatatypeMisalignment"]) | ||
| } | ||
|
|
||
| final override predicate mayThrowException(boolean unconditional) { unconditional = true } | ||
| override predicate raisesException(boolean unconditional) { unconditional = true } | ||
|
|
||
| override TSehException getExceptionType() { any() } | ||
| } |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,12 +11,71 @@ import semmle.code.cpp.models.Models | |
| import semmle.code.cpp.models.interfaces.FunctionInputsAndOutputs | ||
|
|
||
| /** | ||
| * A class that models the exceptional behavior of a function. | ||
| * Represents a type of exception, | ||
| * either Structured Exception Handling (SEH) or C++ exceptions. | ||
| */ | ||
| abstract class ThrowingFunction extends Function { | ||
| newtype TException = | ||
| /** Structured Exception Handling (SEH) exception */ | ||
| TSehException() or | ||
| /** C++ exception */ | ||
| TCxxException() | ||
|
|
||
| /** | ||
| * Functions with information about how an exception is thrown or if one is thrown at all. | ||
| * If throwing details conflict for the same function, IR is assumed | ||
| * to use the most restricted interpretation, meaning taking options | ||
| * that stipulate no exception is raised, before the exception is always raised, | ||
| * before conditional exceptions. | ||
| * | ||
| * Annotations must specify if the exception is from SEH (structured exception handling) | ||
| * or ordinary c++ exceptions. | ||
| */ | ||
| abstract private class ExceptionAnnotation extends Function { | ||
| /** | ||
| * Returns the type of exception this annotation is for, | ||
| * either a CPP exception or a STructured Exception Handling (SEH) exception. | ||
| */ | ||
| abstract TException getExceptionType(); | ||
|
|
||
| /** | ||
| * Holds if the exception type of this annotation is for a Structured Exception Handling (SEH) exception. | ||
| */ | ||
| final predicate isSeh() { this.getExceptionType() = TSehException() } | ||
|
|
||
| /** | ||
| * Holds if the exception type of this annotation is for a CPP exception. | ||
| */ | ||
| final predicate isCxx() { this.getExceptionType() = TCxxException() } | ||
| } | ||
|
|
||
| /** | ||
| * A Function that is known to not throw an exception. | ||
| */ | ||
| abstract class NonThrowingFunction extends ExceptionAnnotation { } | ||
|
|
||
| /** | ||
| * A function this is known to raise an exception. | ||
| */ | ||
| abstract class ThrowingFunction extends ExceptionAnnotation { | ||
| ThrowingFunction() { any() } | ||
|
|
||
| /** | ||
| * Holds if this function may raise an exception during evaluation. | ||
| * If `unconditional` is `false` the function may raise, and if `true` the function | ||
| * will always raise an exception. | ||
| * Do not specify `none()` if no exception is raised, instead use the | ||
| * `NonThrowingFunction` class instead. | ||
| */ | ||
| abstract predicate raisesException(boolean unconditional); | ||
|
|
||
| /** | ||
| * Holds if this function will always raise an exception if called | ||
| */ | ||
| final predicate alwaysRaisesException() { this.raisesException(true) } | ||
|
|
||
| /** | ||
| * Holds if this function may throw an exception during evaluation. | ||
| * If `unconditional` is `true` the function always throws an exception. | ||
| * Holds if this function may raise an exception if called but | ||
| * it is not guaranteed to do so. I.e., the function does not always raise an exception. | ||
| */ | ||
| abstract predicate mayThrowException(boolean unconditional); | ||
| final predicate mayRaiseException() { this.raisesException(false) } | ||
|
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.