Skip to content
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

Add KeSetEventIrql and KeSetEventPaged queries and update IRQL library. #90

Merged
merged 82 commits into from
Nov 21, 2023

Conversation

NateD-MSFT
Copy link
Contributor

@NateD-MSFT NateD-MSFT commented Nov 21, 2023

This PR adds the following queries:

  • KeSetEventIrql: A query that uses our IRQL library to look for calls to KeSetEvent when the IRQL is too high.
  • KeSetEventPaged: A more focused version of the above that uses our paged code library to look for calls to KeSetEvent in paged segments.

We also make the following updates to our IRQL library:

  • Use = instead of .matches() for string comparisons for perf and correctness reasons
  • Add missing variations of IRQL annotation names
  • Refactor our logic for determining expected entry IRQLs for functions, and take into account paged functions in this analysis
  • Increase caching in Irql.qll
  • Create an IrqlDebug.qll library that provides info on why a given CFN has the exit IRQL it does

Note that because we previously squash merged the IRQL work this was based off of into development, early commits in this PR are redundant. f11a56a2c2 onwards are relevant to this PR.

Checklist for Pull Requests

  • Description is filled out.
  • Only one query or related query group is in this pull request.
  • The version number on changed queries has been increased via the @version comment in the file header.
  • All unit tests have been run: (Test README.md).
  • Commands codeql database create and codeql database analyze have completed successfully.
  • A .qhelp file has been added for any new queries or updated if changes have been made to an existing query.

NateD-MSFT and others added 30 commits March 20, 2023 17:46
RI of development branch to main.
Update cpp-all to 0.9.2, cpp-queries to 0.7.4
Signed-off-by: NateD-MSFT <34494373+NateD-MSFT@users.noreply.github.com>
The changes to Irql.qll needed for IrqlSetTooHigh, etc. means we are more likely to see IRQL evaluations that return -1.  Update queries to exclude those numbers.
jacob-ronstadt and others added 24 commits October 20, 2023 12:39
…_snippet.c

Co-authored-by: NateD-MSFT <34494373+NateD-MSFT@users.noreply.github.com>
Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>
…_snippet.c

Co-authored-by: NateD-MSFT <34494373+NateD-MSFT@users.noreply.github.com>
Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>
…_snippet.c

Co-authored-by: NateD-MSFT <34494373+NateD-MSFT@users.noreply.github.com>
Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>
…_snippet.c

Co-authored-by: NateD-MSFT <34494373+NateD-MSFT@users.noreply.github.com>
Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>
Add tests for IrqlSetTooLow and IrqlSetTooHigh
Removes a false positive in our unit tests.
Also make various updates + fixes to the IRQL model.
The previous .matches() clauses were using "_" as wildcards rather than as literal underscores.  While this didn't affect our results directly because of other restrictions we provide, it had some performance penalty.  Rather than try and escape all the underscores (which would require lots of ugly double backslashes) we just switch to the = syntax where possible, which is similarly performant.
@NateD-MSFT NateD-MSFT merged commit c4bf4f8 into development Nov 21, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants