Skip to content

Cannot suppress warning for Windows Drivers #20611

@bit-envoy

Description

@bit-envoy

I cannot suppress warnings while building even basic "Hello World" windows driver project with codeql. I tried to do in source through
// lgtm [cpp/drivers/irql-function-not-annotated]
// codeql [cpp/drivers/irql-function-not-annotated]
#pragma warning(suppress: 28167)

and through global configuration:

name: "CodeQL CPP config"

query-filters:
  - exclude:
      id: 
      - cpp/drivers/irql-function-not-annotated

I am still getting warning which is not suppressed in output sarif:

					"ruleId": "cpp/drivers/irql-function-not-annotated",
					"ruleIndex": 23,
					"rule": {
						"id": "cpp/drivers/irql-function-not-annotated",
						"index": 23
					},
					"message": {
						"text": "Function potentially changes the IRQL without restoring it to the original level, however, the function is not annotated to reflect such a change."
					},
					"locations": [
						{
							"physicalLocation": {
								"artifactLocation": {
									"uri": "MyDriver1/main.c",
									"uriBaseId": "%SRCROOT%",
									"index": 0
								},
								"region": {
									"startLine": 5,
									"startColumn": 6,
									"endColumn": 10
								}
							}
						}
					],
					"partialFingerprints": {
						"primaryLocationLineHash": "a206c19db10e9b5c:1",
						"primaryLocationStartColumnFingerprint": "5"
					}
				},

This is source code for driver:

#include <ntddk.h>
#include <wdm.h>

// lgtm [cpp/drivers/irql-function-not-annotated]
void func()
{
    BOOLEAN locked = FALSE;
    KSPIN_LOCK lock = 0;
    KLOCK_QUEUE_HANDLE lockHandle = { 0 };
    KeInitializeSpinLock(&lock);

    KeAcquireInStackQueuedSpinLock(&lock, &lockHandle);
    locked = TRUE;

    if (locked)
    {
        KeReleaseInStackQueuedSpinLock(&lockHandle);
    }
}

NTSTATUS
DriverEntry(
    _In_ PDRIVER_OBJECT     DriverObject,
    _In_ PUNICODE_STRING    RegistryPath
)
{
    (void)DriverObject;
    (void)RegistryPath;
    func();
    return STATUS_SUCCESS;
}

I am using commands to run codeql:

.\codeql database create .\MyDriver --language=c --source-root="C:\Users\nidanachain\source\repos\MyDriver1" --command="C:\Users\nidanachain\source\repos\MyDriver1\Build.bat" --overwrite --codescanning-config="C:\codeql\config.yml"
.\codeql database analyze .\MyDriver $HOME\.codeql\packages\microsoft\windows-drivers --format=sarifv2.1.0 --output=DriverAnalysis.json

In attachment there is complete driver project
MyDriver1.zip

and sarif output
DriverAnalysis.json

How can I suppress cpp/drivers/irql-function-not-annotated warning from codeql?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions