Skip to content

Commit 9d62d31

Browse files
IrqlLoweredImproperly: Codeql port of c28141 (#157)
* CodeQL port of C28141 * update sarif file
1 parent 267b3e4 commit 9d62d31

File tree

4 files changed

+443
-0
lines changed

4 files changed

+443
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<!DOCTYPE qhelp PUBLIC "-//Semmle//qhelp//EN" "qhelp.dtd">
2+
<qhelp>
3+
<overview>
4+
<p>
5+
The argument causes the IRQ Level to be set below the current IRQL, and this function cannot be used for that purpose
6+
</p>
7+
</overview>
8+
<recommendation>
9+
<p>
10+
A function call that lowers the IRQL at which a caller is executing is being used inappropriately. Typically, the function call lowers the IRQL as part of a more general routine or is intended to raise the caller's IRQL.
11+
</p>
12+
</recommendation>
13+
<example>
14+
<p>
15+
The following code example elicits this warning.
16+
</p>
17+
<sample language="c"> <![CDATA[
18+
KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
19+
KeRaiseIrql(PASSIVE_LEVEL, &OldIrql);
20+
}]]>
21+
</sample>
22+
<p>
23+
The following code example avoids this warning.
24+
</p>
25+
<sample language="c"> <![CDATA[
26+
KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
27+
KeLowerIrql(OldIrql);
28+
}]]>
29+
</sample>
30+
</example>
31+
<semmleNotes>
32+
<p>
33+
</p>
34+
</semmleNotes>
35+
<references>
36+
<li>
37+
<a href="https://learn.microsoft.com/en-us/windows-hardware/drivers/devtest/28141-argument-lowers-irq-level">
38+
C28141
39+
</a>
40+
</li>
41+
</references>
42+
</qhelp>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT license.
3+
/**
4+
* @id cpp/drivers/irql-lowered-improperly
5+
* @kind problem
6+
* @name IRQL Lowered Improperly
7+
* @description A function being called changes the IRQL to below the current IRQL, and the function is not intended for that purpose.
8+
* @platform Desktop
9+
* @feature.area Multiple
10+
* @impact Insecure Coding Practice
11+
* @repro.text
12+
* @owner.email: [email protected]
13+
* @opaqueid CQLD-C28141
14+
* @problem.severity warning
15+
* @precision medium
16+
* @tags correctness
17+
* @scope domainspecific
18+
* @query-version v1
19+
*/
20+
21+
import cpp
22+
import drivers.libraries.Irql
23+
24+
from KeRaiseIrqlCall call, ControlFlowNode prior, int irqlRequirement
25+
where
26+
prior = call.getAPredecessor() and
27+
irqlRequirement = call.getIrqlLevel() and
28+
irqlRequirement != -1 and
29+
irqlRequirement < min(getPotentialExitIrqlAtCfn(prior))
30+
select call,"$@: The function being called changes the IRQL to below the current IRQL, and the function is not intended for that purpose.",
31+
call, call.toString()

0 commit comments

Comments
 (0)