-
Notifications
You must be signed in to change notification settings - Fork 37
IrqlInconsistentWithRequired: CodeQL port of C28166 #159
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
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
52 changes: 52 additions & 0 deletions
52
src/drivers/general/queries/IrqlInconsistentWithRequired/IrqlInconsistentWithRequired.qhelp
This file contains hidden or 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,52 @@ | ||
| <!DOCTYPE qhelp PUBLIC "-//Semmle//qhelp//EN" "qhelp.dtd"> | ||
| <qhelp> | ||
| <overview> | ||
| <p> | ||
| TODO overview | ||
| </p> | ||
| </overview> | ||
| <recommendation> | ||
| <p> | ||
| TODO recommendation | ||
jacob-ronstadt marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| </p> | ||
| </recommendation> | ||
| <example> | ||
| <p> | ||
| Function annotated with _IRQL_requires_same_ but can possibly exit at a different IRQL level. | ||
| </p> | ||
| <sample language="c"> <![CDATA[ | ||
| _IRQL_requires_same_ void fail1(PKIRQL oldIrql) | ||
| { | ||
|
|
||
| if (oldIrql == PASSIVE_LEVEL) | ||
| { | ||
| KeLowerIrql(*oldIrql); | ||
| } | ||
| else | ||
| { | ||
| KeRaiseIrql(DISPATCH_LEVEL, oldIrql); // Function exits at DISPATCH_LEVEL | ||
| } | ||
| } | ||
| }]]> | ||
| </sample> | ||
| <p> | ||
| TODO example 2 | ||
| </p> | ||
| <sample language="c"> <![CDATA[ | ||
| // Example code | ||
| }]]> | ||
| </sample> | ||
| </example> | ||
| <semmleNotes> | ||
| <p> | ||
| TODO notes | ||
| </p> | ||
| </semmleNotes> | ||
| <references> | ||
| <li> | ||
| <a href="example.com"> | ||
| Example link | ||
| </a> | ||
| </li> | ||
| </references> | ||
| </qhelp> | ||
36 changes: 36 additions & 0 deletions
36
src/drivers/general/queries/IrqlInconsistentWithRequired/IrqlInconsistentWithRequired.ql
This file contains hidden or 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,36 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT license. | ||
| /** | ||
| * @id cpp/drivers/irql-inconsistent-with-required | ||
| * @kind problem | ||
| * @name Irql Inconsistent With Required | ||
| * @description The actual IRQL is inconsistent with the required IRQL | ||
| * @platform Desktop | ||
| * @feature.area Multiple | ||
| * @impact Insecure Coding Practice | ||
| * @repro.textAn _IRQL_requires_same_ annotation specifies that the driver should be executing at a particular IRQL when the function completes, but there is at least one path in which the driver is executing at a different IRQL when the function completes. | ||
| * @owner.email: [email protected] | ||
| * @opaqueid CQLD-C28156 | ||
| * @problem.severity warning | ||
| * @precision medium | ||
| * @tags correctness | ||
| * @scope domainspecific | ||
| * @query-version v1 | ||
| */ | ||
|
|
||
| import cpp | ||
| import drivers.libraries.Irql | ||
|
|
||
| from | ||
| IrqlRequiresSameAnnotatedFunction f, int irqlLevelEntry, int irqlLevelExit, | ||
| ControlFlowNode exitCfn, ControlFlowNode entryCfn | ||
| where | ||
| exitCfn = f.getControlFlowScope() and | ||
| entryCfn = f.getBlock() and | ||
jacob-ronstadt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| irqlLevelEntry = getPotentialExitIrqlAtCfn(entryCfn) and | ||
| irqlLevelExit = getPotentialExitIrqlAtCfn(exitCfn) and | ||
| irqlLevelEntry != irqlLevelExit | ||
| select f, | ||
| "Possible IRQL level at function completion inconsistent with the required IRQL level for some path. Irql level expected: " | ||
| + irqlLevelEntry + ". Irql level found: " + irqlLevelExit + | ||
| ". Review the IRQL level of the function." | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.