-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Brodes/seh flow phase1 throwing models #18014
Open
bdrodes
wants to merge
22
commits into
github:main
Choose a base branch
from
microsoft:brodes/seh_flow_phase1_throwing_models
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 15 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
de05aee
Adding model transition to using Throwing.qll.
bdrodes 4b83a45
Change log
bdrodes 1c7b5ae
Merge branch 'main' into brodes/seh_flow_phase1_throwing_models
bdrodes 792231c
Removing SEH default case for function calls as the logic to handle S…
bdrodes 1c874d3
Fixed usage raisesException
bdrodes 5bb765d
Merge branch 'main' into brodes/seh_flow_phase1_throwing_models
bdrodes 26d590a
Putting back deleted file, and deprecating instead. Deprecating mayTh…
bdrodes 63ddd81
Merge branch 'brodes/seh_flow_phase1_throwing_models' of https://gith…
bdrodes 0784776
bringing back mayThrowException to make it cleaner/easier for backwar…
bdrodes ae1ed38
Merge branch 'main' into brodes/seh_flow_phase1_throwing_models
bdrodes a69daa0
Missing change to 'mayThrowException' in StructuredExceptionHandling.qll
bdrodes 23485f1
Merge branch 'brodes/seh_flow_phase1_throwing_models' of https://gith…
bdrodes 4e77756
Changing terminology back to "throws" vs "rasis" for alwaysThrowsExce…
bdrodes 69df07e
Update cpp/ql/lib/change-notes/2024-11-18-throwing-functions.md
bdrodes 6aa7412
Merge branch 'main' into brodes/seh_flow_phase1_throwing_models
bdrodes 9b2590e
Updating PR per review comments. Moving more towards a simplified model.
bdrodes 4412691
Delaying deprecation of ThrowingFunction.
bdrodes 7059fc3
Adding intermediate solution towards deprecating ThrowingFunction
bdrodes 248f1c4
Updating change log
bdrodes 583651b
Missing NonCppThrowingFunction changes in Printf.qll
bdrodes 66cf736
printf formatting.
bdrodes 37365c7
Updating to NonCppThrowingFunction use in IncorrectALlocationErrorHan…
bdrodes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
category: deprecated | ||
--- | ||
* The `NonThrowing` class (`semmle.code.cpp.models.interfaces.NonThrowing`) has been deprecated. Please use the `NonThrowing` class from `semmle.code.cpp.models.interfaces.Throwing` instead. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 5 additions & 3 deletions
8
cpp/ql/lib/semmle/code/cpp/models/implementations/StructuredExceptionHandling.qll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 mayThrowException(boolean unconditional) { unconditional = true } | ||
|
||
override TSehException getExceptionType() { any() } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find this confusing. Together with the
NonThrowing
this seems to say that:Is that the correct reading?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's right. That's what it is saying. It is no longer sufficient to say a function doesn't throw, you have to say how it doesn't throw (which kind of exception doesn't it throw). If they want to say it doesn't throw any you can just return the parent exception type.
The issue we got into with making memcpy nonthrowing is that it is true that it doesn't throw a C++ exception, but it absolutely throws a SEH exception. The mechanics in this PR force users to think about what it is they really want when they say a function throws or doesn't throw.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks.
I wonder if this is all somewhat overly complicated. In my understanding the following cases are interesting:
Is this correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a brief meeting. The conclusion was that my assessment above is correct. The proposal is do something simpler:
NonThrowing
to something likeNonCppThrowingFunction
and introduce a deprecatedNonThrowing
alias.AlwaysSehThrowingFunction
which is used to model functions that always throw an SEH exception.Throwing
class.We should also remove the use of the
Throwing
class in the models, but we can only do that in the next phase when we update the IR (otherwise the IR breaks).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overhauled the PR, let me know if that works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jketema When you say "always throw an SEH exception" does that mean that the function will always throw an SEH exception when called or that the function can only throw an SEH exception but doesn't necessarily always do so? To me the name sounds like the former but I guess it's actually the latter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The former: the function will always throw an SEH exception
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I see. So I guess it's for functions whose purpose is to raise exceptions? Like something along the lines of
throw_my_SEH_exception
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes:
RaiseException
,ExRaiseAccessViolation
,ExRaiseDatatypeMisalignment
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, thanks :)