Skip to content
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

Linux4 8 kaslr support, take2 #420

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

bneuburg
Copy link
Contributor

This is an updated version of Linux > 4.8 KASLR detection and dismisses the linux_kaslr_shift plugin entirely.

@atcuno implemented KASLR detection and calculation in upstreams Linux overlay, however at various spots incorrect calculations were done regarding which shift (physical vs virtual) was used.

I tested the attached patches with kernel 4.9 amd64 memory dumps that had KASLR en- and disabled.

Moreover a small typo is fixed.

One upstream change since my PR #385 made the DTB finder skip the only valid DTB in the images I checked, therefore I commented those lines (the active_mm checks).

@atcuno found a nicer way to determine the virtual shift; instead of walking through the paging levels, looking up the path to a target physical page and then calculating the diff between observed and expected virtual address, he simply used the virtual address stored in the files member of init_tasks task_struct that points to the randomized address of symbol init_files. By calculating the difference to the init_files value in System.map you can also determine the virtual_shift.

I'd like to note that even though KASLR detection possibly finds the correct values with this PR the linux_kaslr_shift plugin might still come in handy, since in contrast to the way it is handled now it will not stop DTB finding after the first possible hit but looks further to find additional DTBs, so in cases where the first found DTB is not correct it can still help out.
However I'd like to use the more elegant init_files approach for the plugin as well and will refactor this first before resubmitting.

If this check is active the DTB scanner won't find a valid DTB in my
4.9 KASLR samples.
After commenting this out it just works.
@koromodako
Copy link

Also work on a 4.9.0 kernel, thank you very much ! Eager to see this pull request merged ! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants