SKEE: A Lightweight Secure Kernel-level Execution Environment for ARM

aney666·2023년 2월 13일
0

논문정리

목록 보기
3/4
  • This post is a personal summary of SKEE: A Lightweight Secure Kernel-level Execution Environment for ARM.

SKEE Overview

  1. Isolation

    • First step
      - Create a protected virtual address for SKEE

      • Modifying the memory translation tables used by the kernel.
      • So that none of the translation entries point to the physical memory regions used by SKEE.
      • 즉, kernel이 접근 가능한 공간을 SKEE를 위해서 carve out 하고, kernel의 translation table을 수정하여 SKEE의 physical memory regions을 point 하는 entry가 없도록 함으로써 격리.
      • 새로운 addess space를 보호하기 위해서 모든 memory translation tables이 이 새롭게 보호되는 주소 공간의 일부여야 하고, 그래서 이 table은 SKEE만 접근이 가능해야 함. kernel은 어떤 table에도 접근하지 못해 virtual memory access permission을 수정하지 못 하게 됨.
    • Second step
      - Restrict the kernel access to the MMU.

      • CPU로부터 특정 MMU의 기능들을 빼앗아서 SKEE에 의해서 보호되고 있는 translation table이 아닌 다른 table을 생성하지 않도록 함.
      • translation table의 위치를 바꾸거나, verify 되지 않은 table을 사용한다거나 등을 instrumenting 함
    • 정리
      - kernel이 존재하는 memory translation tables를 변경하지 못하게, verify 되지 않은 table들을 사용하도록 MMU의 configuration들을 변경하지 못하게 막음

      • SKEE에 의해서 제공되는 격리를 위반하지 못 함
      • MMU나 SKEE's address space에 접근하는 것을 막음
  2. Secure Context Switching

    • Switching memory translation table의 원리와 동일
      -> 그러나 해당 switching은 higher privilege level에서 일어나지만, SKEE의 경우에는 같은 privilege level에서 일어남.

    • 격리를 유지하면서 switch 하기 위해서 새로운 기술 사용
      - kernel이 isolated 된 환경으로 jump 하도록 switch gate를 지명하는 것.
      - 해당 gate는 atomic 하고 deterministic 하게 설계됨.
      - atomic : 보호된 주소 공간에 접근 가능할 때 커널이 해당 공간에 대한 control을 얻지 못하도록 막기 위한 property
      - deterministic : SKEE로의 switching이 항상 지정된 entry point를 통과하고 적절한 security check 들을 통과하도록 요구하는 property
      -> 이 두 개의 properties 들로 인해 SKEE의 주소 공간은 kernel에 노출되기 어렵다.

  3. Kernel Monitoring and Protection

    • SKEE 는 전체 system의 memory range에 접근이 가능함
    • kernel이 접근할 수 있는 영역의 access permission을 선택적으로 조절이 가능함.

=> The Design section includes how to achieve these.

SKEE vs ARM TrustZone

Switching time

  • SKEE : the number of CPU cycles required for switching to and from the isolated environment is in the range of few hundred cycles.

  • TrustZone : may reach up to thousands of CPU cycles.
    => Switching time to and from SKEE is much faster than switching time to and from the ARM TrustZone environment.
    => SKEE is not only lightweight, but can be also faster than TrustZone based systems.

Privileged layer

  • SKEE : aimes at keeping these layers more secure through reducing thier code base and maintenance effort

  • TrustZone and virtualization extensions : designed to replace higher privileged layers.

Memory Management

32-bit ARMv7

  • Controling the MMU is done through special instructions that move the value of general purpose register to system management registers of coprocessor 15.
  • Use three MMU control register
    => TTBCR (Translation Table Base Control Register), TTBR0 (Translation Table Base Register 0), TTBR1 (Translation Table Base Register 1)
    • TTBR0 and TTBR1 point to different sets of memory translation tables.
    • TTBCR chooses which of the two sets is used when translating a particular memory address.
      => TTBRC contains a 3 bits called TTBRC.N that determines the virtual address range translated by each of the two registers.
      (The starting address of TTBR1 translation is effected by TTBCR.N's value.)

64-bit ARMv8

  • The 64-bit virtual address range is split into two subranges.
    - (1) which is translated using TTBR0, is at the bottom of the address space. (User processes)
    - (2) which is translated usint TTBR1, is at the top of the address space. (virtual address space)

  • On ARMv8, the MMU control registers can be changed by MSR instruction, which moves the value of general purpose registers to system management registers.
    - MSR instruction can use the Zero Register (XZR) to move the value zero to any of the special registers.

Virtualizaiton Layer

  • ARM's virtualization extensions provide an additional mode of privileged execution to host the hypervisor.
  • Privileged mode is also eqquipped with an additional memory translation layer, called Seconde Stage (S2) address translation, which is pointed to by the vttbr register.
  • S2가 enabled 할 때, guest OS로부터 온 physical memory access를 IPA (Intermediate Physical Addresses)로 여기고, S2 memory translation table를 사용하여 실제 physical addesses로 바꿈.
  • S2 memory address translation은 guest OS가 사용 가능한 physical address range를 customize 하기 위해서 hypervisor에 의해 사용됨.

ASID

  • Address Space Identifier
  • virtual memory page는 global과 non-global이 존재하는데, global memory page는 모든 system에서 접근이 가능함. 그래서 TLB(Translation Lookaside Buffer)라는 single cache가 이 page의 translation을 위해서 존재함. Non-global memory page는 process 마다 존재함. 그래서 TLB가 하나의 non-global memory page translation에 여러 개 존재할 수 있음. 이는 ASID로 구별됨. 다른 process로 switch 할 때 ASID로 구분함. CPU는 현재 ASID와 연관되어 있는 유일한 하나의 TLB entry만 사용 가능함.
  • ASID is used to enhance the performance by eliminating the need of flushing the TLB on every process switch.
  • TLB flusing means the overhead occured by TLB miss.

32-bit ARMv7

  • Current ASID is defined by the Context ID Register (CONTEXTIDR).

64-bit ARMv8

  • Current ASID is defined by the translation table base registers.

SKEE Security Guarantees

  • SKEE는 kernel이 메모리 레이아웃이나 접근 권한을 수정하는 것을 금지한다
    -> kernel이 완전히 compromises 되어도 격리된 환경은 revoke 할 수 없음
  • potentially compromised 된 kernel로부터 격리된 환경으로의 switching은 엄격하게 관리되는 switch gate를 통해서만 진행함
    -> 격리된 환경은 input parameter들을 안전하게 검사할 수 있음

PXN (Privileged eXecute Never)

  • PxN bit (in ARM architecture) : Whether that memory's code can be execute in kernel mode.

SKEE Assumptions

  • SKEE는 kernel이 WX
  • SKEE는 OS memory mapping 에 오직 TTBR0를 사용하게 하고, TTBR1은 SKEE가 독점적으로 사용함.
  • 더불어 virtual address space의 가장 lowest한 2GB는 오직 non-privileged한 user space code로 사용한다.
    => OS의 기능성에 영향을 주지 않는 이유?
    - TTBR0TTBR1은 같은 virtual address range를 mapping 함. -> 하나만 사용해도 충분하다!
    - 대부분의 OS들은 최소한 2GB의 메모리를 user address space를 위해 사용함.
  • (64-bit ARMv8) SKEE는 physical address가 0x0부터 시작하는 memory page가 필요함(독점적으로 사용). => 보통은 ROM이 위치하여 system boot process가 시작되는 부분임.
    - virtualization의 S2 memory translation table을 사용하면 쉽게 충족됨
    => S2는 guest OS가 사용 가능한 physical memory range를 customize 할 수 있기 때문
    => OS가 S2 table에 의해서 강제로 translate 되기 때문에 해당 page의 physical address를 0x0으로 생각함.
    - higher privileged sw는 원래 0x0을 그대로 보고, 부팅 시스템을 사용함.

SKEE Design

  • main goal

    The main goal is to provide a lightweight execution environment to enable a security tool to run in isolation from the kernel without active involvement of higher privileged system components, such as TrustZone or virtualization layer.

  • SKEE는 secure boot sequence를 수정하여 커널과 SKEE를 위해 분리된 두 개의 address space를 만든다.

  • 부팅 이후에 kernel을 이용한 potential attack이 존재하더라도 해당 attack들은 SKEE를 compromise 할 수 없음 (공간이 독립되어 있기 때문에). 그래서 SKEE에 의해서 host 되는 secure tool들은 kernel을 계속 모니터링 하고, 공격을 막을 수 있음.

1. SKEE Isolation

  • physical address를 mapping 하고 있는 page table (memory tranlation table)이 없으면 kernel은 해당 physical address에 접근할 수 없음.

  • SKEE는 이를 이용하여 kernel이 특정 physical memory range에 접근할 수 없도록 two step solution 을 사용함

  • Creating a Protected Address Space
    - kernel이 own code를 수정할 수 없게 하고, SKEE에 접근할 수 없게 해야 함 (3가지 rule 존재)

    1. removing all entries that map to either the SKEE environment or the kernel's memory translation tables
    2. mapping the kernel code and the SKEE switch gate as read-only
    3. restricting all other memory areas, including kernel data and user level memory, from executing privileged code using the PXN bit.
  • Restrict Kernel Access to the MMU
    - kernel이 분리된 address space를 위반하지 않도록, 오직 instumented 된 page table만 사용해야 한다.
    - 이는 특정 MMU register의 수정을 제한함으로써 목적 달성이 가능함. -> 특정 MMU register의 수정 제한 -> kernel이 translation table base register를 변경하는 것을 못하게 막음.
    - SKEE는 kernel code에서 특정 instruction을 찾아서 제거하고, switch gate로 jump 하도록 후킹할 수 있음. (ARM이 고정된 사이즈의 instruction set을 사용하기 때문에 바이너리에서 특정 instruction을 찾는 것이 쉬움)

Voca

  • For the sake of ~ 어떤 목적이나 혜택을 위해
  • peripheral 주위에 있는
  • introspect : examine one's own thoughts or feelings
  • escalate 확대시키다
  • brief 간결한
  • testify 증명하다
  • time sharing model 시분할 모델
  • at any point of time 언제든지
  • non-trivial 중요한
  • breach 위반
  • novel 신기한, 기발한
  • carve out 도려내다
  • tamper 손을 대다, 함부로 변경하다
  • deprive from 빼앗다
  • designate 지명하다, 지정되다
  • rigorous 엄격한

0개의 댓글