DynamoRIO / DynamoRIO/dynamorio
ASSERT (9.0.19202 git.exe/dot.exe) NtCreateSection in os_map_file fails with STATUS_ACCESS_DENIED
- Dominant language
- C
- Stars
- 3.2k
- Forks
- 629
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 31
Description
**Describe the bug**
drcov fails with
- `Internal Error: DynamoRIO debug check failure: D:\a\dynamorio\dynamorio\core\win32\module.c:4760 is_readable_pe_base(module_base)` (64 bit)
- `Error opening instrumentation library C:\UserProgs\DynamoRIO-Windows\tools\lib32\release\drcov.dll` (32-bit)
The underlying issue seems to be that `NtCreateSection` in `os_map_file` fails with `STATUS_ACCESS_DENIED`:
```
privload_load: loading C:\UserProgs\DynamoRIO-Windows\tools\lib64\release\drcov.dll
os_map_file: NtCreateSection error 0x00000000c0000022
```
**To Reproduce**
Command (64-bit program):
```
C:\UserProgs\DynamoRIO-Windows\bin64\drrun.exe -verbose -late -debug -loglevel 4 -t drcov -- git --version
```
Output:
```
INFO: reading tool config file C:\UserProgs\DynamoRIO-Windows/tools/drcov.drrun64
INFO: client 0 path: C:\UserProgs\DynamoRIO-Windows\tools\lib64\release\drcov.dll
INFO: client 1 path: C:\UserProgs\DynamoRIO-Windows\tools\lib32\release\drcov.dll
INFO: targeting application: "C:\Program Files\Git\cmd\git.exe"
INFO: app cmdline: "git" "--version"
INFO: configuration directory is "C:\Users\ContainerAdministrator/dynamorio"
INFO: created child with pid 32300 for C:\Program Files\Git\cmd\git.exe
INFO: registering client with id=0 path=|C:\UserProgs\DynamoRIO-Windows\tools\lib64\release\drcov.dll| ops=||
INFO: registering client with id=0 path=|C:\UserProgs\DynamoRIO-Windows\tools\lib32\release\drcov.dll| ops=|| alt-bitwidth
INFO: waiting forever for app to exit...
```
Log: [git.exe.0.36464.txt](https://github.com/DynamoRIO/dynamorio/files/9267291/git.exe.0.36464.txt)
Command (32-bit program):
```
C:\UserProgs\DynamoRIO-Windows\bin32\drrun.exe -verbose -late -debug -loglevel 4 -t drcov -- dot -V
```
Output:
```
INFO: reading tool config file C:\UserProgs\DynamoRIO-Windows/tools/drcov.drrun32
INFO: client 0 path: C:\UserProgs\DynamoRIO-Windows\tools\lib32\release\drcov.dll
INFO: client 1 path: C:\UserProgs\DynamoRIO-Windows\tools\lib32\release\drcov.dll
INFO: targeting application: "C:\Program Files (x86)\Graphviz\bin\dot.exe"
INFO: app cmdline: "dot" "-V"
INFO: configuration directory is "C:\Users\ContainerAdministrator/dynamorio"
INFO: created child with pid 48304 for C:\Program Files (x86)\Graphviz\bin\dot.exe
INFO: registering client with id=0 path=|C:\UserProgs\DynamoRIO-Windows\tools\lib32\release\drcov.dll| ops=||
INFO: registering client with id=0 path=|C:\UserProgs\DynamoRIO-Windows\tools\lib32\release\drcov.dll| ops=|| alt-bitwidth
INFO: waiting forever for app to exit...
```
Log: [dot.exe.0.124784.txt](https://github.com/DynamoRIO/dynamorio/files/9267312/dot.exe.0.124784.txt)
**Expected behavior**
Opening instrumentation library `drcov.dll` should work.
**Screenshots or Pasted Text**
See above.
**Versions**
- What version of DynamoRIO are you using? 9.0.19202
- Does the latest build from https://github.com/DynamoRIO/dynamorio/releases solve the problem? No
- What operating system version are you running on? ("Windows 10" is *not* sufficient: give the release number.) Docker image [`mcr.microsoft.com/windows/servercore`](https://hub.docker.com/_/microsoft-windows-servercore). `[System.Environment]::OSVersion.Version` reports 10.0.17763.0
- Is your application 32-bit or 64-bit? Both 32-bit and 64-bit are affected.
**Additional context**
Currently we have an old and custom build 8.x version we use.
There in the `os_map_file()` the call to the `nt_create_section()` function was patched. If `osprot` is `0x80` (`PAGE_EXECUTE_WRITECOPY`), `PAGE_EXECUTE` (`0x10`) is passed as an argument instead of `osprot`.
This seems to work fine so far for us, but unsure of the implications of such a change. And if write access is not needed here, a better fix would be probably to not request it form `os_map_file()` in the first place.
Contributor guide
Assessment
This issue has not been assessed yet.