KernelTestFramework / ktf

Kernel Test Framework
BSD 2-Clause "Simplified" License
140 stars 18 forks source link

Further fixes for usermode handling #289

Closed wipawel closed 1 year ago

wipawel commented 1 year ago

This PR is based on #284. Please review the #284 first and rebase this one to limit the changes. Only top 3 commits differ.

    arch,entry,usermode: fix user pagetable mappings alignment

    The exception handlers as well as interrupt handlers need to be
    properly mapped into user pagetables. Add global symbols to find their
    addresses and align the beginning on a page boundary.

    Similar entry_usermode() and syscall_handler_entry() need to be aligned
    and ideally share the same page.

    The syscall_exit() and similar routines do not need user pagetable
    mappings.

    Add also an explicit mapping for user_cr3 variable.
    arch,entry: cleanup: rearrange code

    Signed-off-by: Pawel Wieczorkiewicz <wipawel@grsecurity.net>
    arch,usermode: fix user stack handling in enter_usermode()

    We need to preserve user stack address on percpu first, to use allow
    simple stack switching.

    We need to switch to user pagetables before putting IRET frame onto
    user stack.

    Signed-off-by: Pawel Wieczorkiewicz <wipawel@grsecurity.net>