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

implement shadow stacks #455

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Commits on Sep 18, 2024

  1. mm: implement VMKernelShadowStack

    The initialization and pt_flags are a bit special for shadow stack
    pages, so this warrants a new `VirtualMapping` implementations.
    
    Signed-off-by: Tom Dohrmann <erbse.13@gmx.de>
    Freax13 committed Sep 18, 2024
    Configuration menu
    Copy the full SHA
    a29d1c9 View commit details
    Browse the repository at this point in the history
  2. percpu: allocate an initial shadow stack

    This shadow stack is used when not using a task's shadow stack.
    
    Signed-off-by: Tom Dohrmann <erbse.13@gmx.de>
    Freax13 committed Sep 18, 2024
    Configuration menu
    Copy the full SHA
    56b214e View commit details
    Browse the repository at this point in the history
  3. percpu: setup ISST

    The interrupt shadow stack table (ISST) is very similar to the
    interrupt stack table (IST) except that it contains shadow stack
    addresses instead of normal stack addresses.
    
    Signed-off-by: Tom Dohrmann <erbse.13@gmx.de>
    Freax13 committed Sep 18, 2024
    Configuration menu
    Copy the full SHA
    0fbbd41 View commit details
    Browse the repository at this point in the history
  4. task: allocate shadow stacks for each task

    Each task needs to a normal shadow stack and shadow stack used for
    exception handling.
    
    Signed-off-by: Tom Dohrmann <erbse.13@gmx.de>
    Freax13 committed Sep 18, 2024
    Configuration menu
    Copy the full SHA
    1bc3c0c View commit details
    Browse the repository at this point in the history
  5. idt: add shadow stack pointer to exception context

    Some exception handlers will need to update the shadow stack, so they
    need to know the shadow stack pointer at the time of the exception.
    
    Signed-off-by: Tom Dohrmann <erbse.13@gmx.de>
    Freax13 committed Sep 18, 2024
    Configuration menu
    Copy the full SHA
    8d2db3f View commit details
    Browse the repository at this point in the history
  6. idt: update return address on shadow stack

    Whenever we update the return address on the shadow stack, we'll also
    need to update the return address on the shadow stack.
    
    Signed-off-by: Tom Dohrmann <erbse.13@gmx.de>
    Freax13 committed Sep 18, 2024
    Configuration menu
    Copy the full SHA
    5a3d5fe View commit details
    Browse the repository at this point in the history
  7. schedule: switch to special stack during context switches

    We need to guard against IRQs coming in after switching to the new page tables
    and before switching to the new stack.
    
    Signed-off-by: Tom Dohrmann <erbse.13@gmx.de>
    Freax13 committed Sep 18, 2024
    Configuration menu
    Copy the full SHA
    ab39c92 View commit details
    Browse the repository at this point in the history
  8. schedule: switch shadow stacks in context switch

    Each task has separate shadow stacks, so we need to switch them when
    switching tasks.
    
    Signed-off-by: Tom Dohrmann <erbse.13@gmx.de>
    Freax13 committed Sep 18, 2024
    Configuration menu
    Copy the full SHA
    640249f View commit details
    Browse the repository at this point in the history
  9. svsm: enable shadow stack

    This enables shadow stacks for the BSP.
    
    Signed-off-by: Tom Dohrmann <erbse.13@gmx.de>
    Freax13 committed Sep 18, 2024
    Configuration menu
    Copy the full SHA
    d4e4487 View commit details
    Browse the repository at this point in the history
  10. vmsa: enable shadow stacks

    This enables shadow stacks on the secondary APs.
    
    Signed-off-by: Tom Dohrmann <erbse.13@gmx.de>
    Freax13 committed Sep 18, 2024
    Configuration menu
    Copy the full SHA
    f189193 View commit details
    Browse the repository at this point in the history
  11. idt: implement #CP handler

    This exception handler will be executed when the CPU detects a mismatch
    between the return address on the stack and the return address on the
    shadow stack.
    
    Signed-off-by: Tom Dohrmann <erbse.13@gmx.de>
    Freax13 committed Sep 18, 2024
    Configuration menu
    Copy the full SHA
    207847f View commit details
    Browse the repository at this point in the history
  12. shadow_stack: determine support at runtime

    Trusted CPUID values are hard to come by, so let's just try to enable
    CET in CR4 and handle failure gracefully.
    
    Signed-off-by: Tom Dohrmann <erbse.13@gmx.de>
    Freax13 committed Sep 18, 2024
    Configuration menu
    Copy the full SHA
    cc5c763 View commit details
    Browse the repository at this point in the history