Skip to content

Commit e59bc7a

Browse files
committed
docs: add missing steps to Fail_Driver_Pool_Leak Sample Driver README
1 parent 9e6aab1 commit e59bc7a

1 file changed

Lines changed: 24 additions & 19 deletions

File tree

tools/dv/kmdf/fail_driver_pool_leak/README.md

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
1-
# Fail_Driver_Pool_Leak Sample
1+
# Fail_Driver_Pool_Leak Sample Driver
22

3-
This sample KMDF Fail Driver demonstrates the capabilities and features of **Driver Verifier** and the **Device Fundamentals Tests**.
3+
This sample KMDF Fail Driver is designed to demonstrate the capabilities and features of **Driver Verifier** and the **Device Fundamentals Tests** for a driver written in Rust.
44

5-
It allocates a pool of memory to a global buffer when a supported device is added by the PnP Manager and intentionally does not free it before the driver is unloaded. This memory leak fault is a system vulnerability that could lead to security and performance issues and bad user experience.
5+
The driver allocates a pool of memory to a global buffer in its `evt_driver_device_add` function when a supported device is added by the PnP Manager. The driver intentionally does not free it anywhere, even in the `evt_driver_unload` callback, which get called before the driver is unloaded. This memory leak fault is a system vulnerability that could lead to security and performance issues and ultimately a bad user experience.
66

7-
By enabling Driver Verifier on this driver, this pool leak violation can be caught before the driver is unloaded and with an active KDNET session, the bug can be analyzed further.
7+
By enabling Driver Verifier on a driver, such violations can be caught and mitigated early in the development cycle. With an active KDNET session, the bugcheck can be analyzed further using WinDbg. The steps listed below demonstrate how to build, deploy, enable Driver Verifier, run Device Fundamentals Tests and debug the driver.
88

99
NOTE: The driver uses WDM's ExAllocatePool2 API directly to allocate memory for its buffer. Ideally, such allocations should be freed by using ExFreePool API. A cleaner way to manage memory in a WDF Driver is to use [wdfmemory](https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdfmemory/)
1010

11-
1211
## Steps to reproduce the issue
1312

1413
1. Clone the repository and navigate to the project root.
1514

16-
2. Build the driver project using the following command in a WDK environment (or EWDK prompt) -
15+
2. Install [Clang](https://clang.llvm.org/get_started.html)
16+
* Easy install option:
17+
```
18+
winget install LLVM.LLVM
19+
```
20+
21+
3. Build the driver project using the following command in an [EWDK environment](https://learn.microsoft.com/en-us/legal/windows/hardware/enterprise-wdk-license-2022) -
1722
```
1823
cargo make
1924
```
20-
3. Prepare a target system (a Hyper-V VM can be used) for testing
25+
4. Prepare a target system (a Hyper-V VM can be used) for testing
2126
2227
Follow the below steps to setup the test system -
2328
1. Disable Secure boot and start the system
@@ -37,11 +42,11 @@ NOTE: The driver uses WDM's ExAllocatePool2 API directly to allocate memory for
3742
shutdown -r -t 0
3843
```
3944
40-
4. Copy the driver package, available under ".\target\debug\fail_driver_pool_leak_package" to the target system.
45+
5. Copy the driver package, available under ".\target\debug\fail_driver_pool_leak_package" to the target system.
4146
42-
5. Copy "devgen.exe" from host to the target system. Alternatively you may install WDK on the target system and add the directory that contains "devgen.exe" to PATH variable.
47+
6. Copy "devgen.exe" from host to the target system. Alternatively you may install WDK on the target system and add the directory that contains "devgen.exe" to PATH variable.
4348
44-
6. Install the driver package and create the device in the target system using the below commands -
49+
7. Install the driver package and create the device in the target system using the below commands -
4550
```
4651
cd "fail_driver_pool_leak_package"
4752
devgen.exe /add /bus ROOT /hardwareid "fail_driver_pool_leak"
@@ -50,7 +55,7 @@ NOTE: The driver uses WDM's ExAllocatePool2 API directly to allocate memory for
5055
5156
pnputil.exe /add-driver .\fail_driver_pool_leak.inf /install
5257
```
53-
7. Enable Driver Verifier for 'fail_driver_pool_leak.sys' driver package
58+
8. Enable Driver Verifier for 'fail_driver_pool_leak.sys' driver package
5459
1. Open run command prompt (Start + R) or cmd as administator and run "verifier"
5560
2. In the verifier manager,
5661
- Create Standard Settings
@@ -59,23 +64,23 @@ NOTE: The driver uses WDM's ExAllocatePool2 API directly to allocate memory for
5964
- Finish
6065
- Restart the system
6166
62-
8. Follow the steps in https://learn.microsoft.com/en-us/windows-hardware/drivers/develop/how-to-test-a-driver-at-runtime-from-a-command-prompt to run tests against the device managed by this driver
67+
9. Follow the steps in https://learn.microsoft.com/en-us/windows-hardware/drivers/develop/how-to-test-a-driver-at-runtime-from-a-command-prompt to run tests against the device managed by this driver
6368
64-
9. Install TAEF and WDTF on the test computer and run the following test -
69+
10. Install TAEF and WDTF on the test computer and run the following test -
6570
```
6671
cd "C:\Program Files (x86)\Windows Kits\10\Testing\Tests\Additional Tests\x64\DevFund"
6772
TE.exe .\Devfund_PnPDTest_WLK_Certification.dll /P:"DQ=DeviceID='ROOT\DEVGEN\{PASTE-DEVICE-ID-HERE}'" --rebootResumeOption:Manual
6873
```
6974
70-
10. The test will lead to a Bugcheck and a BlueScreen on the target system with the following error -
75+
11. The test will lead to a Bugcheck and a BlueScreen on the target system with the following error -
7176
```
7277
DRIVER_VERIFIER_DETECTED_VIOLATION (c4)
73-
```
74-
The logs will be available in WinDbg
75-
run ```!analyze -v``` for detailed bugcheck report
76-
run ```!verifier 3 fail_driver_pool_leak.sys``` for info on the allocations that were leaked that caused the bugcheck.
78+
```
79+
Run ```!analyze -v``` for detailed bugcheck report
80+
81+
Run ```!verifier 3 fail_driver_pool_leak.sys``` for info on the allocations that were leaked that caused the bugcheck.
7782
78-
11. (Alternatively), the bugcheck can be observed when all the devices managed by this driver are removed, i.e, when the driver is unloaded from the system.
83+
12. (Alternatively), the bugcheck can be observed when all the devices managed by this driver are removed, i.e, when the driver is unloaded from the system.
7984
You may use pnputil/devcon to enumerate and remove the devices -
8085
```
8186
# To enumerate the devices

0 commit comments

Comments
 (0)