Skip to content

[CMLIB] Clean volatile registry entries in the same manner as Windows #1883

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

Merged
merged 2 commits into from
Aug 27, 2019

Conversation

maharmstone
Copy link
Contributor

This fixes the crashes in HvpGetCellMapped on Windows Server 2003 when booting from Freeloader, as mentioned in maharmstone/btrfs#16.

When the bootloader loads the system hive, it cleans the data pertaining to any volatile keys. The Windows bootloader does this by setting SubKeyCounts[Volatile] to 0. After boot, the kernel marks any cell where this is 0 but SubKeyLists[Volatile] isn't HCELL_NIL as dirty, meaning that the sanitized version will then get flushed to the disk.

Because Freeloader sets SubKeyLists[Volatile] to HCELL_NIL straightaway, Windows thinks the cell is clean, and can unload it without flushing. If it then reads it from the disk, it will crash in HvpGetCellMapped due to the stale volatile pointers.

If you break on nt!CmpInitializeSystemHive on Windows and "gu" to the let the function run, you'll see that DirtyVector of the HHIVE has only the first 8 bits set. If you run it using the official bootloader, it'll have a lot more than that.

Bear in mind that I haven't tested this either on ReactOS, or any other version of Windows - but it's definitely the case for WS2003. You probably want to do your own testing before accepting this patch.

@HBelusca HBelusca self-assigned this Aug 26, 2019
@HBelusca
Copy link
Contributor

@maharmstone : You said that while investigating on Windows you see that the SubKeyLists[Volatile] value is not HCELL_NIL. Could you please tell me which one you actually read instead?

@HBelusca HBelusca added the review pending For PRs undergoing review. label Aug 26, 2019
@maharmstone
Copy link
Contributor Author

Whatever happened to be its value when it was flushed to disk on the last boot. 80016178 in this particular case, I believe.

@HBelusca HBelusca removed the review pending For PRs undergoing review. label Aug 27, 2019
@HBelusca HBelusca merged commit e6a9aaf into reactos:master Aug 27, 2019
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.

2 participants