From cd5daf0037ccf76f13d100d59d5e363abba73f50 Mon Sep 17 00:00:00 2001 From: Taylor Beebe Date: Mon, 18 Mar 2024 14:00:17 -0700 Subject: [PATCH] Paging Audit: Fix SMM Paging Audit Data Collection and Parsing The SMM paging audit needed to be updated to match the improvements made to the DXE audit. This change: 1. Reformats the SMM HTML template 2. Fixes the parsing of GDT and IDT entries 3. Adds the platform info data collection - [x] Impacts functionality? - **Functionality** - Does the change ultimately impact how firmware functions? - Examples: Add a new library, publish a new PPI, update an algorithm, ... - [ ] Impacts security? - **Security** - Does the change have a direct security impact on an application, flow, or firmware? - Examples: Crypto algorithm change, buffer overflow fix, parameter validation improvement, ... - [ ] Breaking change? - **Breaking change** - Will anyone consuming this change experience a break in build or boot behavior? - Examples: Add a new library class, move a module to a different repo, call a function in a new library class in a pre-existing module, ... - [x] Includes tests? - **Tests** - Does the change include any explicit test code? - Examples: Unit tests, integration tests, robot tests, ... - [ ] Includes documentation? - **Documentation** - Does the change contain explicit documentation additions outside direct code modifications (and comments)? - Examples: Update readme file, add feature readme file, link to documentation on an a separate Web page, ... How This Was Tested Tested on Q35 and SBSA by running the paging audit with various memory protection profiles. Tested on an SMM-enabled Surface device. Integration Instructions N/A --- .../UEFI/Smm/App/SmmPagingAuditTestApp.c | 1 + .../PagingAudit/Windows/MemoryRangeObjects.py | 7 +- .../Windows/SmmPaging_template.html | 543 ++++++++++-------- 3 files changed, 317 insertions(+), 234 deletions(-) diff --git a/UefiTestingPkg/AuditTests/PagingAudit/UEFI/Smm/App/SmmPagingAuditTestApp.c b/UefiTestingPkg/AuditTests/PagingAudit/UEFI/Smm/App/SmmPagingAuditTestApp.c index 45f01bc194..ef88173886 100644 --- a/UefiTestingPkg/AuditTests/PagingAudit/UEFI/Smm/App/SmmPagingAuditTestApp.c +++ b/UefiTestingPkg/AuditTests/PagingAudit/UEFI/Smm/App/SmmPagingAuditTestApp.c @@ -477,6 +477,7 @@ SmmPagingAuditTestAppEntryPoint ( { UINTN StringLength; + DumpPlatforminfo (); DumpProcessorSpecificHandlers (TRUE, &StringLength); AllocateMemoryMapBuffer (); MemoryMapDumpHandler (TRUE, &StringLength); diff --git a/UefiTestingPkg/AuditTests/PagingAudit/Windows/MemoryRangeObjects.py b/UefiTestingPkg/AuditTests/PagingAudit/Windows/MemoryRangeObjects.py index a8eba76413..47c15e863d 100644 --- a/UefiTestingPkg/AuditTests/PagingAudit/Windows/MemoryRangeObjects.py +++ b/UefiTestingPkg/AuditTests/PagingAudit/Windows/MemoryRangeObjects.py @@ -311,10 +311,11 @@ def toDictionary(self): if self.ImageName == None: section_type = "Not Tracked" else: - # if an image range can't be read or executed, this is almost certainly - # an error. if self.Nx == 1 and self.ReadWrite == 0: - section_type = "ERROR" + if ("GDT" in self.ImageName or "IDT" in self.ImageName): + section_type = "Descriptor Table" + else: + section_type = "ERROR" elif self.Nx == 1: section_type = "DATA" elif self.ReadWrite == 0: diff --git a/UefiTestingPkg/AuditTests/PagingAudit/Windows/SmmPaging_template.html b/UefiTestingPkg/AuditTests/PagingAudit/Windows/SmmPaging_template.html index 958ed6710d..c03260d416 100644 --- a/UefiTestingPkg/AuditTests/PagingAudit/Windows/SmmPaging_template.html +++ b/UefiTestingPkg/AuditTests/PagingAudit/Windows/SmmPaging_template.html @@ -1,14 +1,19 @@  + - Smm Paging Analysis + DXE Paging Analysis - - - - +
-

Smm Paging Analysis

+

DXE Paging Analysis

Actions
- Filters: + +

@@ -109,10 +146,12 @@

Test Results

End Address Page Size # of Pages + Present Read/Write Execute Privilege UEFI Memory Type + GCD Memory Type Section Type Special Memory Usage UEFI Memory Contents @@ -139,18 +178,24 @@

Parsing Tool Errors

- SMM Paging Analysis Template Version: 1.00
- SMM Paging Analysis Tool Version:
+ DXE Paging Analysis Template Version: 1.00
+ DXE Paging Analysis Tool Version:

License


- Copyright (C) Microsoft Corporation. All rights reserved.
+ Copyright (C) Microsoft Corporation. All rights + reserved.
- All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

+ All rights reserved. Redistribution and use in source and binary forms, with or + without modification, are permitted provided that the following conditions are + met:
+ 1. Redistributions of source code must retain the above copyright notice, this list + of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright notice, this + list of conditions and the following disclaimer in the documentation and/or other + materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED @@ -175,16 +220,29 @@

External Licenses

- - - - - - + + + + + + - + + \ No newline at end of file