Repository navigation
Conversation
_translate_swap sent a paged out entry at any level of the walk to the page file, at PageFileHigh << invalid_bits. A paged out page directory entry holds the location of a page table, so this read 2 MB (4 MB without PAE) of the page file at a scaled offset as if it were data. PageFileHigh of all ones, which means the PTE has to be rebuilt from the VAD, was also sent to the page file. Resolve only faults at the page table entry level, and leave all ones alone. Adds hand-built page table tests for the three Windows layers, run in CI as a unit test step that needs no image.
Kernels whose _MMPTE_SOFTWARE has SwizzleBit (from the August 2018 L1TF updates onwards) keep the page file number at bit 12 instead of bit 1, and add InvalidPteMask to software PTEs whose SwizzleBit is clear. The Windows layers read the number at bit 1 and used PageFileHigh as is, so demand-zero PTEs were read from the page file at 0x2000000 and most paged out pages went to the wrong page file or offset. - WinSoftwarePteLayout copies the bit positions of PageFileLow and SwizzleBit, and InvalidPteMask from MiState.Hardware or the older global MiInvalidPteMask, onto the kernel's layer as three optional settings. Process layers inherit them with the rest of the layer configuration. - With these settings, _translate_swap reads the page file number at PageFileLow, removes the mask only when SwizzleBit is clear, and accepts any non-zero protection instead of requiring bit 7, which is part of the protection and is clear for read-only and execute pages. - Without them, the old layout and the bit 7 test are kept.
_translate_swap returned the start of the page file slot, so a read that did not start on a page boundary got the bytes from the start of the slot. Reads of whole pages were right, which is why page level checks did not show it. Return the slot plus the offset inside the page, as _translate does for a present page.
When the kernel has SwizzleBit but its InvalidPteMask could not be read, or was rejected, the layout was still set and no mask was removed, so a demand-zero PTE was again read from the page file at 0x2000000. Keep a mask of 0, which is what CPUs that need no mask report, and leave PTEs whose swizzle bit is clear unresolved when the mask is unknown. Adds tests for this, for a read-only paged out page table, and for a page file number without a swap layer.
23703a5 to
28934db
Compare
|
I've updated the branch:
I could only test 64-bit images of two builds (10.0.19041 and 10.0.26100) against real bytes. If you have 32-bit images or other builds with their page files, could you run the branch over them? The description lists what I couldn't test. |
|
Update (2026-11-18): Some of the PTEs in the second table have I tested the "Not tested" items myself on six Hyper-V VMs: Windows Server 2016, 2019, 2022 and 2025, Windows 10 21H2 x86 (PAE), and Windows 11 24H2. Inside each VM, a script allocated 64 MB buffers well past the RAM size and wrote a marker into every page: process number, buffer and page index. It held the buffers until most of them were paged out. The dump was a complete dump taken by NMI into a dedicated dump file, and pagefile.sys was copied from the VM's disk after power-off. Each page of these buffers that Volatility read from pagefile.sys was then checked against its own marker:
Beyond the marked buffers, I looked at every software PTE inside a process VAD that points into pagefile.sys. The table shows how many each version translated to the slot given by the kernel's own layout and mask:
On 14393 the kernel has no SwizzleBit and PageFileLow starts at bit 1, and the automagic picked that up. develop gets these PTEs right too, except the 7,622 whose protection doesn't have bit 7 set (read-only and similar). The marked buffers were all read-write, which is why both versions agree on them. On the x86 PAE kernel the automagic found PageFileLow at bit 12 and SwizzleBit at bit 4, as on x64. InvalidPteMask was 0 in all six (host CPU i9-12900K). develop also sent 123 PTEs with PageFileHigh 0xFFFFFFFF on x86, and 37 compressed-store PTEs on Windows 11, to other places in pagefile.sys; the branch doesn't. MemProcFS 5.19.0 read the same bytes for all of these pages on Server 2016, 2022, 2025 and Windows 11. It couldn't open the x86 dump. On Server 2019 it differed on half the pages until its kernel symbols were in place; that was on the MemProcFS side (ufrisk/MemProcFS#432). With the symbols, 655,017 of 655,018 matched, and the remaining page was unreadable in MemProcFS. Without a page file, windows.pslist, cmdline, dlllist, envars, vadinfo, malfind, svcscan and netscan gave the same output on develop and the branch for all six dumps (48 of 48). With pagefile.sys attached, the branch returns more: for example 42 to 744 more envars rows per dump, and command lines and DLL paths that develop shows as empty. Later I also checked swapfile.sys, given as the second swap location. All page file 1 PTEs (274 on x86, 25 on Windows 11) went to the right slot in swapfile.sys; develop read none of them. Only the 25 Windows 11 pages could be compared with MemProcFS: they matched, but all 25 were zero pages. Still not covered: pages in the compressed store (#2081). |
|
I tested this branch on seven VirtualBox guests with known page content. The builds are 19045, 22631 and 26100, and InvalidPteMask is non-zero on all three. That covers the "non-zero mask on builds other than 19041" case from your list. Setup
Pages in pagefile.sys whose page table is resident (
Pages expected to stay unreadable. These came back as exceptions, never as bytes. No configuration of the branch (with or without the page file) returned a wrong or other-marker page in any run (0 of 917,504 pages).
Plugin parity without a page file. The JSON output of Not covered by this test
|
|
Update (2026-11-18): 6,340 of the 550,744 PTEs below, including 1,148 of the 7,622, have Thank you for running this. A non-zero InvalidPteMask on 22631 and 26100 was the case I couldn't produce. Apart from the two 19041 images, everything I could dump reports a mask of 0: my laptop (26100) and six Hyper-V guests, all on one i9-12900K host. For the three items your test didn't reach, this is what I have. It doesn't replace a test like yours. Bit 7 Server 2016 (14393) from my earlier comment has 7,622 page-file PTEs whose protection doesn't have bit 7 set (6,432 read-only, 1,190 with protection 0x10 or 0x18). develop leaves those unreadable. The branch sends all 550,744 page-file PTEs inside process VADs in that dump to the slot given by the kernel's layout, and MemProcFS 5.19.0 read the same bytes as the branch for all 550,744 pages. This is the only image with its page file where I can separate the bit-7 change. On DC01 (Server 2012 R2, in the description) it is also the only difference from develop, 369 PTEs, but I have no page file to check their bytes. On the newer builds develop already reads the page file number from the wrong bits, so the bit-7 change can't be measured on its own there. Offset inside a page (commit 3) I read paged-out pages at a random offset and length, 600 reads per image, with every fourth read crossing into the next page. Reads inside a page were compared with pagefile.sys at slot + offset, where the slot comes from my own page-table walk rather than from Volatility. It uses the same rule as the branch, so that column checks the offset. The MemProcFS columns are the independent check: every read that returned bytes was compared with MemProcFS reading the same address and length.
The remaining reads (0 to 19 per image, all of them crossing reads) raised an exception and returned no bytes. With only the first two commits, 440 of the 450 inside reads on DESKTOP came back with the bytes at the start of the slot instead of the bytes at the offset. The other 10 matched pagefile.sys at slot + offset. Server 2016 and 2019 aren't in the table. My sampler assumed the newer PTE layout and found only 53 candidates on 14393 (the 52 readable ones all matched). On Server 2019 MemProcFS didn't have its kernel symbols when this ran.
swapfile.sys Still thin, as the description says. In my earlier comment, all page file 1 PTEs (274 on x86, 25 on Windows 11) went to the right slot in swapfile.sys. The only pages I could compare with MemProcFS were those 25, and all were zero. I can share the sampling scripts if they would help. |
|
Thanks, that covers the three gaps well enough for me to follow, and the numbers line up with your earlier comment. I also ran A few follow-ups, mostly so the evidence doesn't depend only on MemProcFS agreeing with the branch: Bit 7
Offset inside a page
swapfile.sys
Yes, please share the sampling scripts ( |
…ated Kernels whose _MMPTE_SOFTWARE has PageFileAllocated leave a page file offset in PageFileHigh of some PTEs that have it clear. In the images checked, every decommitted (protection 0x10) and guard page PTE with an offset was among them. Their slot was free in the page file's AllocationBitmap or also named by a PTE with the bit set, and in test VMs such a slot held that other page, as markers written in the guest showed. The automagic now also reads the position of PageFileAllocated (it moves between kernels), and _translate_swap leaves PTEs with it clear unresolved, so without a swap layer they are no longer reported as swapped. Kernels without the field, and layers without the kernel's layout, are unchanged. The tests also read across two paged out pages in slots that are not next to each other, and each test slot now ends with its own tag. Co-authored-by: pmj2744 <267242619+pmj2744@users.noreply.github.com> Co-authored-by: ydam113 <81817139+ydam113@users.noreply.github.com>
|
Thank you for running the tests on the merge base. Your question about protection 0x10 turned up a problem that this branch made worse and that develop already has, so that comes first. PTEs with PageFileAllocated clear On 14393, all 1,030 PTEs with protection 0x10 have
That is 6,340 of the 550,744 page file PTEs. On the eight images below, the two groups behave differently. DESKTOP is left out because of its smeared page tables, and DC01 because I couldn't read its bitmap. Counts are page file 0 PTEs inside a VAD with the slot inside the file. Each cell gives PTEs / slots free in AllocationBitmap / slots also named by another PTE with the bit set.
On the seven images other than the laptop, protection 0x10 and the guard values 0x11 and 0x14 occur only with the bit clear. Where I could find out what a bit-clear slot holds, it held something else:
Reading these slots returns a free slot's old contents or another page. MemProcFS reads these PTEs the same way, which is why matching it didn't catch this. develop reads the ones with bit 7 set: on 14393 that is 5,192 of the 6,340, including every guard page. WinDbg's I can't say what these PTEs are.
Commit 5 ( What changes:
Re-run with commit 5:
Bit 7 Of the 7,622 PTEs, 6,474 have PageFileAllocated set: 6,383 read-only and 91 at 0x18. All their slots are allocated, and no other PTE with the bit set names them. The other 1,148 have it clear (49 read-only, 1,030 at 0x10, 69 at 0x18), so commit 5 leaves them alone. The allocation bitmap by protection, allocated / free:
For the bit-clear ones, "allocated" mostly means another PTE with the bit set names the slot. Offset inside a page The 10 reads with commits 1-2. In all 10, the bytes at the start of the slot equal the bytes at the offset. 3 pages are all zero, 1 is a single repeated non-zero byte, and in the other 6 both ranges are zero. The 19 failed crossing reads on DESKTOP. All but one failed on the second page:
Two page file pages. I added
All of them equal pagefile.sys read directly at both slots. With commit 5, some reads that worked before now fail:
In every one of them, the first or second page has PageFileAllocated clear. On DESKTOP, 9 of the 12 slots are free, and the slots are named by up to 141 PTEs. Tests. There are now 74, and develop fails 48 of them. On commit 5, these CI steps pass:
Scripts. They are on the
I've updated the description for commit 5. Numbers measured before it are marked as such. |
|
Follow-up on PageFileAllocated, with what I couldn't say in my last comment. What the kernel does The page fault handler reads the page file slot only when PageFileAllocated is set. Otherwise it resolves the fault as demand zero.
So commit 5 matches the kernel. For these PTEs the right content is a zero page, or no access for decommitted pages, and Volatility leaves them unresolved as it does demand-zero PTEs. I checked 14393, 19041, 19044 x86 and 26100, not 17763, 20348 or Windows 8/8.1. There is a second kind of bit-clear PTE: PageFileHigh = 1 with both bits clear, e.g. Owners of the remaining slots on 14393 In my last comment, 886 bit-clear PTEs (on 834 slots) pointed to a used slot that no PTE with the bit set in my walk names.
Re-run with commit 5 on all six VMs
MemProcFS MemProcFS reads PTEs with PageFileAllocated clear the same way. On the five VMs where Volatility read a marker pair from such a PTE's slot before commit 5 (118, 180, 113, 106 and 84 pages on Server 2016, 2019, 2022, 2025 and Windows 11), MemProcFS returns the same marker for all 601. I've opened ufrisk/MemProcFS#441 there. The new scripts are on the same |
|
I checked the PageFileAllocated gate on the builds you hadn't looked at: 17763, 20348 and 9600 x64, plus 9200 x86. I did it statically: In all of them
The PDB layouts match: PageFileAllocated is bit 2 on 17763/20348 and bit 14 on 9200/9600, where PageFileReserved is bit 13 and InStore bit 12. So the gate depends on the kernel's own |
|
Thanks for checking these four builds. I looked at the kernels of two of my VMs the same way (
I've added your results to the description, under commit 5 and in "Not tested". 9600 x64 and 9200 x86 are now checked in the kernel code (Windows 8 x64 and 8.1 x86 are not), but I still haven't run commit 5 on a bit 14 kernel with a page file. |
|
I went back to two items in "Not tested" and to the kernels with PageFileAllocated at bit 24. None of them needed new images. Nothing in the branch changes; the description gets four edits (listed at the end). 1. PTEs with PageFileHigh = 1 and both page file bits clear are reset PTEs. The kernel tests for this exact shape in Where it is used:
This is consistent with the MEM_RESET documentation: "data in the memory range ... is no longer of interest. The pages should not be read from or written to the paging file" (VirtualAlloc). So PageFileHigh = 1 here marks a reset page; it doesn't name a slot. How many there are, counted with the kernel's rule on the same probe data as before (software PTEs inside VADs):
2. Windows 8 x64 and 8.1 x86 fault handlers. I took both kernels from the July 10, 2018 security-only updates in the Microsoft Update Catalog. That is the month before the August 2018 updates that moved the bits on 9600.
The SHA-1 in each file name matches the download. Both PDBs put PageFileReserved at bit 13 and PageFileAllocated at bit 14.
3. Kernels with PageFileAllocated at bit 24. These are 15 x64 ISFs in the symbol pack, and no x86 ones. I fetched their PDBs from the Microsoft symbol server by GUID. The source paths in each PDB name the build branch:
None of them is the branch of a shipped kernel I could check: 9200.22490 reports Scripts. Description changes:
|
This picks up the page file part of #581 and #778 on current develop. It only touches the Windows Intel layers and adds one Windows automagic. There are five commits:
PageFileAllocated, added after review (comment).What goes wrong
WindowsMixin._translate_swapdecodes a software (paged out) PTE with fixed rules:_MMPTE_SOFTWAREhasSwizzleBitkeepPageFileLowat bits 12-15. On those kernels, bits 1-4 hold PageFileReserved, PageFileAllocated, ColdPage and SwizzleBit.PageFileHighused as is. On the same kernels, software PTEs whose SwizzleBit is clear carryInvalidPteMask. With a mask of0x200000000000, a demand-zero PTE reads as PageFileHigh0x2000, i.e. page file offset0x2000000. The mask depends on the CPU: on the Windows 11 laptop below it is 0, and only points 1, 3, 4 and 5 apply.PageFileHigh << invalid_bits. A paged out page directory entry therefore becomes a 2 MB (or 4 MB) read at a scaled offset.PageFileAllocatedclear, and their slot does not hold their page (see commit 5). develop reads those with bit 7 set, guard pages among them.When the layout changed. In the ISFs of Volatility's own symbol pack (
volatility3-test-data,windows.zip), SwizzleBit and the bit 12 layout first appear in kernels 6.1.7601.24214, 6.3.9600.19101, 10.0.14393.2430 and 10.0.17134.228. Unpatched builds of the same releases (e.g. 9600.19067, 17134.191) still use bit 1. 6.1.7601.24214 is the kernel in KB4343900 and 17134.228 is KB4343909. Both are the August 14, 2018 updates that added the L1 Terminal Fault mitigations. So patched Windows 7 / 8.1 and early Windows 10 images are affected too, not only 1803 and later.Change
Commit 1 (no symbols needed):
_translate_swaponly resolves faults at the page table entry level, and leaves PageFileHigh of all ones alone (that PTE has to be rebuilt from the VAD).Commit 2:
WinSoftwarePteLayout(priority 35, afterKernelPDBScanner) reads the bit positions of_MMPTE_SOFTWARE.PageFileLowand.SwizzleBitfrom the kernel's symbols.InvalidPteMaskfromMiState.Hardware. Where that field doesn't exist, it reads the older globalMiInvalidPteMaskinstead: 26 kernel ISFs with SwizzleBit in the symbol pack have only the global, 13 x64 and 13 PAE.page_file_low_bit,swizzle_bitandinvalid_pte_mask. Commit 5 adds a fourth._translate_swap:page_file_low_bit;Commit 3:
_translate_swapreturned the start of the page file slot without the offset inside the page, so a read that does not start on a page boundary got the bytes from the start of the slot. develop has the same code. It now returns the slot plus the offset, as_translatedoes for a present page. Reads of whole pages were right, which is why the page level checks below did not show it (see "Reads inside a page" under Results).Commit 4: if the kernel has SwizzleBit but the mask can't be read (or has bits outside PageFileHigh), commit 2 still set the layout and removed nothing, which brings back the demand-zero reads at
0x2000000. A mask of 0, which CPUs that need no mask report, is now kept, and when the mask is unknown, PTEs whose SwizzleBit is clear are left unresolved instead of being read from a guessed slot.Commit 5: some PTEs carry a page file offset in PageFileHigh but have
_MMPTE_SOFTWARE.PageFileAllocatedclear.PageFileAllocatedis: bit 2, 13, 14 or 24 in the x86/x64 kernels of the symbol pack (24 only in kernels from pre-release Windows 8 branches). It stores it as a fourth setting,page_file_allocated_bit._translate_swapleaves PTEs with it clear unresolved.With the number now read from the right bits, the order of
--single-swap-locationsmatters: the n-th file is used for page file number n (pagefile.sys is normally 0 and swapfile.sys 1).Which decoding is right
The existing proposals disagree on PTEs whose SwizzleBit is 1 and whose PageFileHigh has the mask bit set:
vmm/mm/mm_win.c) removes it only when SwizzleBit is 0.WinDbg. On the CI image
win-10_19041-2025_03.dmp, I sampled 287 user-space software PTEs across 45 processes, up to 25 per kind (SwizzleBit × mask bit × page file number × bit 7, demand zero, all ones). I ran!pteon each in kd (WinDbg 1.2611.4001.0).0000200000000080as DemandZero, and develop reads it from the page file at0x2000000.The kernel's own allocation bitmap. I checked each decoded slot against
_MMPAGING_FILE.Bitmaps->AllocationBitmap. This covers all software PTEs inside a VAD, walking page tables directly under present upper-level entries.The first row leaves out the PTEs with PageFileAllocated clear (8,705 on DESKTOP, 24,900 on the CI image), which the other rows count. I chose that rule after seeing these counts, so the row shows the rule agrees with the bitmap, not independent evidence for it; the marker results under "Tested later on six VMs" are that.
Results
Image. DESKTOP memory of the public DFIR Madness case "The Case of the Stolen Szechuan Sauce" (Windows 10 x64, 19041), with its pagefile.sys (as in my comment on #778). The counts are software PTEs inside a VAD, translated with each version's
_translate.Bytes and plugins:
Bytes. Every page this branch reads from pagefile.sys is the 4 KB at the slot above. I compared them with MemProcFS 5.19 on the same page file, reading page by page. MemProcFS's scatter read can return bytes that change with the order of the request for pages it cannot read, so it is not a reference for those pages.
Before commit 5 the branch read 14,545 pages: 14,074 the same as MemProcFS, 68 other, 403 unreadable. The rest of this point describes that run. Outside the 70 2 MB regions described next, MemProcFS can't read 9 and every other page matches.
All 68 differing pages and 394 of the unreadable ones lie in 70 regions whose page table, as reached by the walk, does not look like one:
0x15ff000000de840f, which reads as instruction bytes).Of 150 random tables with no difference, 146 show none of this. These look like page tables smeared during acquisition. There MemProcFS returns other resident pages (66) or zeros (2), and none of its bytes match a page file slot under any of the decodings above, so the difference does not come from the page file decoding. develop matches MemProcFS for 2 of 18,752 pages.
Reads inside a page. I tried reading the compressed store on DESKTOP through these layers (not part of this PR). 70 compressed blocks lay inside MemCompression pages that are in pagefile.sys. Read before commit 3, none of them decompressed, and ntdll's
RtlDecompressBufferrejected them too. The bytes at the right offset of the same slots decompress to what MemProcFS returns for 70 of 70, and after commit 3 the reads through the layer do the same. Decoding all 95,900 store PTEs again with commit 5 gives the same 66,572 pages with the same bytes.Plugin output.
pslist,cmdline,dlllist,envars,vadinfo,malfind,svcscanandnetscanis identical to develop on the CI image, on DESKTOP and on DC01 (24 of 24, compared on commit 4). Commit 5 changes none of the 24.pslist,svcscanandnetscanare unchanged. The others read more:cmdlinerecovers one command line, which matches MemProcFS.dlllistfills 12 empty names and finds 20 more modules. Of the 32 new rows, 27 match MemProcFS by base and name, and 4 are found but still have no name. One is a bogus entry (base0x2, empty name) that the list walk now reaches.envarsgives 62 more variables, andvadinfo13 more file names.windows.malfindwith the page file gives 8 rows on develop and 7 on this branch. The dropped VAD (PID 3316,0x10c6baf0000) was reported only because one of its 16 pages was demand-zero and came back as the 4 KB at pagefile.sys0x2000000. MemProcFS shows content for that region from the compressed store, which Volatility does not read either way.Other kernels:
page_file_low_bit = 1andpage_file_allocated_bit = 14.MiState.Hardware.InvalidPteMaskis 0 on this CPU, and kd shows the same. None of the 5,082,057 software PTEs inside a VAD has SwizzleBit set, so the mask part changes nothing here.!ptematches this PR's decoding for 125 of 125 sampled PTEs (5 kinds × 25, 57 processes). 26 of them are page file PTEs with PageFileAllocated clear. kd decodes those the same way, and since commit 5 the branch leaves them unresolved.Tests
test/test_windows_swap_ptes.pybuilds page tables by hand forWindowsIntel32e,WindowsIntelPAEandWindowsIntel. It also runs the automagic against small ISFs: mask in MiState, global mask, no mask, a bad mask, values already set, a layer without a kernel offset, a non-Windows layer, PageFileAllocated at bit 2 and at bit 13, and inheritance throughbuild_configuration. It also covers:That is 74 tests, needing no image and running in about two seconds. On develop 48 fail; the 26 that pass check behaviour that must not change. They run in a new CI step.
Locally, on the last commit, these CI steps pass: Windows plugins on
win-10_19041-2025_03.dmp63, Windows volshell 2, and ruff. Linux plugins (41) and Linux volshell (1) passed on commit 4. Commit 5 changes no Linux code, and I didn't re-run them.Same place as #2043. This touches the same place in
WindowsMixinas #2043: both add methods after_page_is_valid. With both applied the conflict is only textual, and both test files pass.Version. I have not bumped the framework version or added an
API_CHANGES.mdentry, since the new settings are optional. Happy to add a minor bump if you want one.Tested later on six VMs (comment): Server 2016 (14393), 2019 (17763), 2022 (20348) and 2025 (26100), Windows 10 21H2 x86 PAE (19044), and Windows 11 24H2 (26100), each a complete dump plus pagefile.sys. That comment is from before commit 5:
Later checks (comment):
MI_IS_RESET_PTE(14393, 17763, 20348, 26100 and 19044 x86), and while such a page is clean,MiCheckReservePageFileSpacereserves no page file space for it (14393, 20348, 26100). They are 212,638 of the 231,821 PTEs with both bits clear on my laptop's live dump, and 1,025 of 3,291 on the CI image. develop reads those with bit 7 set from a page file slot (all but one on the laptop, at slot 1 of pagefile.sys; all 1,025 on the CI image, at slot0x2001). Commit 5 leaves them unresolved (comment).Not tested:
If you have such images with their page files, running this branch over them would help a lot.
windows.dlllist,envarsandmalfindwith--single-swap-locationsare where differences show. The comparison scripts I used are on thepr2080-check-scriptsbranch of my fork.Not changed here:
_maxphyaddr = 45workaround from Temporary workaround for changes in transition PTE #475 already cuts off. On a CPU where the mask sits lower, transition PFNs would still carry it.This came out of a student team project on local LLMs for digital forensics at Joongbu University, advised by @Slothmor3 and @ring7a. Team: @vmaca123, @pmj2744, @ydam113.