DMA Support for the Sancus Architecture Lightweight and Open-Source - - PowerPoint PPT Presentation

dma support for the sancus architecture
SMART_READER_LITE
LIVE PREVIEW

DMA Support for the Sancus Architecture Lightweight and Open-Source - - PowerPoint PPT Presentation

DMA Support for the Sancus Architecture Lightweight and Open-Source Trusted Computing for the IoT Sergio Seminara seminara@kth.se KTH - Kungliga Tekniska Hgskola Examiner: prof. Mads Dam Supervisor: prof. Roberto Guanciale Seminara (KTH)


slide-1
SLIDE 1

DMA Support for the Sancus Architecture

Lightweight and Open-Source Trusted Computing for the IoT Sergio Seminara

seminara@kth.se

KTH - Kungliga Tekniska Högskola

Examiner: prof. Mads Dam Supervisor: prof. Roberto Guanciale

Seminara (KTH) DMA Support for the Sancus Architecture 19 February 2019 0 / 27

slide-2
SLIDE 2

Introduction Goal of the Thesis

Sancus 2.0 DMA Goal of the Thesis To extend Sancus 2.0 architecture with DMA capabilities, without affecting its security guarantees

Seminara (KTH) DMA Support for the Sancus Architecture 19 February 2019 1 / 27

slide-3
SLIDE 3

Introduction Goal of the Thesis

Contributions of the Thesis:

1 Provide a background on Sancus and PMA in general 2 Show that a direct implementation of DMA breaks security guarantees 3 Propose secure DMA implementations on Sancus that preserve

security properties

Seminara (KTH) DMA Support for the Sancus Architecture 19 February 2019 2 / 27

slide-4
SLIDE 4

Introduction Goal of the Thesis

What is DMA?

Direct Memory Access (DMA) It is a feature of CPUs that allows hardware subsystems to directly access the memory, without the participation of the Control Unit (CU). Without DMA, the CPU would be fully occupied during I/O operations. In this sense, DMA speeds up the system, by unburdening the CPU from I/O loads.

Seminara (KTH) DMA Support for the Sancus Architecture 19 February 2019 3 / 27

slide-5
SLIDE 5

Introduction Goal of the Thesis

What is Sancus 2.0?

Sancus Target architecture of the thesis is Sancusa[5], an open-source, lightweight PMA with a specific focus for networked embedded devices.

aSancus version with secure DMA support is currently maintained on GitHub

at https://github.com/S3rg7o/sancus-core

Protected Modules Architectures Security architectures running independently from an operating system, that can execute code in an isolated area of the memory.

Seminara (KTH) DMA Support for the Sancus Architecture 19 February 2019 4 / 27

slide-6
SLIDE 6

Introduction PMAs and PC Based MAC

Secure Code Execution on Embedded Devices

Embedded device are required to be cheap in terms of: – Chip area – Chip complexity – Power consumption → unsuitable to implement established solutions from high-end devices world A promising solution is found in Protected (software) Module Architectures, security architectures that offers: – Isolated execution of protected software module – Secure remote attestation – Divide-and-conquer approach, as complex software is splitted into smaller protected modules, easier to verify [4]

Seminara (KTH) DMA Support for the Sancus Architecture 19 February 2019 5 / 27

slide-7
SLIDE 7

Introduction PMAs and PC Based MAC

Program-Counter Based Memory Access Control

PC Based MAC Memory protection technique which sets different memory permissions depending on the current value of the PC. Hardware-only solution, with minimal TCB1 Strong modules isolation and confidentiality guarantees Low cost → compatible with lightweight embedded devices

Memory access rights PC from \ to Protected Unprotected Entry point Code Data Entry point r - x r - x r w - r w x Text section r - x r - x r w - r w x Unprotected \ Other SMs

  • - x
  • - -
  • - -

r w x

1Trusted Computing Base Seminara (KTH) DMA Support for the Sancus Architecture 19 February 2019 6 / 27

slide-8
SLIDE 8

Introduction PMAs and PC Based MAC

PMAs PC Based Memory Access Control Memory Protection

  • n

Embdedded Devices

Seminara (KTH) DMA Support for the Sancus Architecture 19 February 2019 7 / 27

slide-9
SLIDE 9

Introduction Sancus Overview

System Model

A single infrastructure provider IP owns and administers a set of networked microprocessor-based systems, referred as nodes Ni. N1 N2 IP SP1 SP2

. . .

SPj

SM1,1 SM2,1

· · ·

SM2,2 SMj,k

· · ·

. . .

Seminara (KTH) DMA Support for the Sancus Architecture 19 February 2019 8 / 27

slide-10
SLIDE 10

Introduction Sancus Overview

Security Properties:

SMs Isolation Remote Attestation Secure Communication & Secure Linking Secure Key Management

Seminara (KTH) DMA Support for the Sancus Architecture 19 February 2019 9 / 27

slide-11
SLIDE 11

Introduction Sancus Overview

Attacker Model

Attackers can:

Manipulate all the software on the node and act as software providers Control the communication network, independently of its security protocol Perform protocol-level attacks on cryptographic functions Plug-in their own peripherals before the system is started. Any further alteration at runtime is not considered in this model

Attackers cannot:

Have physical access to the hardware of the system. At anytime they cannot: – Access CPU internal registers – Place probes on memory buses – Disconnect components at runtime Break cryptographic primitives

Seminara (KTH) DMA Support for the Sancus Architecture 19 February 2019 10 / 27

slide-12
SLIDE 12

Introduction Sancus Overview

Software Module on a Sancus Node

Processor protect(layout,SP) instruction supervises SMs deployment

Unprotected Memory Next ID Caller ID KN Node Protected storage area

A software module is composed by: Code section, containing protected code and constants, that can be entered only via few predefined entry points Data section, containing the module private data

Seminara (KTH) DMA Support for the Sancus Architecture 19 February 2019 11 / 27

slide-13
SLIDE 13

Introduction Sancus Overview

Software Module on a Sancus Node

Processor protect(layout,SP) instruction supervises SMs deployment

Unprotected Entry point Code & constants Unprotected SM1 text section Protected data SM1 data section Unprotected Memory TS1 TE1 DS1 DE1 KN,SP,SM1 IDSM1 TSn TEn DSn DEn KN,SP,SMn IDSMn Next ID Caller ID KN SM1 metadata SMn metadata Layout Key ID Protected storage area Node

The node key KN, together with all SMs keys KN,SP,SMi, are stored in the Protected Storage Area (PSA). PSA is not mapped into the system memory keys never leak on Sancus!

Seminara (KTH) DMA Support for the Sancus Architecture 19 February 2019 11 / 27

slide-14
SLIDE 14

Introduction Sancus Overview

Trusted Computing Base (TCB)

The set of hardware or software components critical for the security of the system. Sancus TCB is hardware-only

Memory Backbone

RAM

  • r

ROM RAM

Peripherals

Frontend

MAB Violation Peripheral Bus

Crypto Unit Execution Unit

MAL Layout Key SM1 MAL Layout Key SM2

SM Control TCB

DMA Peripherals

Key & Layout

Address registers Number of words

FSM

DMA Controller

DMA Interface

Seminara (KTH) DMA Support for the Sancus Architecture 19 February 2019 12 / 27

slide-15
SLIDE 15

Introduction Sancus Overview

DMA Controller

Sancus is provided with a default DMA controller. Main benefits from its inclusion in the system are: Multiplex different devices, with a positional priority arbitration Incorporate all the complexity of the DMA protocol in use on Sancus

Seminara (KTH) DMA Support for the Sancus Architecture 19 February 2019 13 / 27

slide-16
SLIDE 16

Problem Statement

PMAs PC Based Memory Access Control Memory Protection

  • n

Embdedded Devices DMA?

Seminara (KTH) DMA Support for the Sancus Architecture 19 February 2019 14 / 27

slide-17
SLIDE 17

Problem Statement DMA Support for PMAs

PMAs generally do not support DMA

PC based MAC is enforced over the CPU memory access bus (MAB).

  • What if the untrusted element resides outside CPU domain?
  • What if there was a way to directly access the memory, bypassing any

CPU control, so that no violation is raised on illegal accesses?

Seminara (KTH) DMA Support for the Sancus Architecture 19 February 2019 15 / 27

slide-18
SLIDE 18

Problem Statement DMA Support for PMAs

DMA Exploitation on PMAs

Watch out An attacker with DMA capabilities can tamper with any location of the system memory at runtime, as DMA bypasses any MMU-like control.

An example of DMA exploitation, for the Sancus architecture, is provided at https://github.com/S3rg7o/sancus-examples/blob/master/hello-DMA/Readme.md. Seminara (KTH) DMA Support for the Sancus Architecture 19 February 2019 16 / 27

slide-19
SLIDE 19

Extending DMA on Sancus

Sancus 2.0 What about Sancus?

It does not support DMA natively

Seminara (KTH) DMA Support for the Sancus Architecture 19 February 2019 17 / 27

slide-20
SLIDE 20

Extending DMA on Sancus Direct DMA Implementation

Direct DMA Implementation

Breaks Sancus security guarantees!

Every memory location can be accessed, including the SMs protected

  • sections. Modules isolation reneges

The KN,SP,SM key is computed only once, on module deployment. If isolation reneges, it can’t be no longer be considered a sufficient assurance of modules integrity Nodes and modules keys are inaccessible from DMA SMs isolation is a crucial security property An attacker can entirely rewrite the text section of a module, making it de facto a Trojan horse Although alarming, this scenario differs from keys disclosure since attacker’s computational capabilities are still confined to compromised node

Seminara (KTH) DMA Support for the Sancus Architecture 19 February 2019 18 / 27

slide-21
SLIDE 21

Extending DMA on Sancus Solution Tree

Need for solutions!

DMA on PMAs? 1) No DMA in the system Allow DMA in the system 3) Exclude DMA from protected memory 2) Enforce PC-based memory access control 4) Allow access to specific locations in SMs data sections

Seminara (KTH) DMA Support for the Sancus Architecture 19 February 2019 19 / 27

slide-22
SLIDE 22

Extending DMA on Sancus No DMA in the System

1) No DMA in the System

Sacrifice DMA capabilities in order to preserve security guarantees, without adding complexity to the architecture.

PC != TS TS ≤ PC < TE !(TS ≤ PREV_PC < TE) (1) !(TS ≤ PC < TE) DS ≤ MAB < DE (2) violation !(TS ≤ PC < TE) TS ≤ MAB < TE (3) WRITE_MEM == 1 TS ≤ MAB < TE (4) TS: Text Section Start Add TE: Text Section End Add DS: Data Section Start Add DE: Data Section End Add

Figure: Example of Memory Access Logic for a single SM

Seminara (KTH) DMA Support for the Sancus Architecture 19 February 2019 20 / 27

slide-23
SLIDE 23

Extending DMA on Sancus No DMA in the System

1) No DMA in the System

Sacrifice DMA capabilities in order to preserve security guarantees, without adding complexity to the architecture. Pros

  • Doesn’t add complexity to the

system

  • Reasonable trade-off for

lightweight, resource constrained, systems Cons

  • Does not provide any DMA

capability

Seminara (KTH) DMA Support for the Sancus Architecture 19 February 2019 20 / 27

slide-24
SLIDE 24

Extending DMA on Sancus PC based MAC over DMA

2) Enforce PC based MAC over DMA Accesses

PC != TS TS ≤ PC < TE !(TS ≤ PREV_PC < TE) (1) !(TS ≤ PC < TE) DS ≤

MAB or DMA_ADDR

< DE (2) violation !(TS ≤ PC < TE) TS ≤

MAB or DMA_ADDR

< TE (3) WRITE_MEM == 1 TS ≤

MAB or DMA_ADDR

< TE (4) TS: Text Section Start Add TE: Text Section End Add DS: Data Section Start Add DE: Data Section End Add

Seminara (KTH) DMA Support for the Sancus Architecture 19 February 2019 21 / 27

slide-25
SLIDE 25

Extending DMA on Sancus PC based MAC over DMA

2) Enforce PC based MAC over DMA Accesses

Pros

  • Allows DMA in the system
  • Expands the already present

Sancus MAL circuitry with minimal hardware additions Cons

  • Flawed idea of relating two

independent entities as the PC and the DMA bus

  • Opens to privilege escalation

attacks, as PC is free to vary during a DMA operation

Seminara (KTH) DMA Support for the Sancus Architecture 19 February 2019 21 / 27

slide-26
SLIDE 26

Extending DMA on Sancus Exclude DMA from Protected Memory

3) Exclude DMA from Protected Memory

PC != TS TS ≤ PC < TE !(TS ≤ PREV_PC < TE) (1) !(TS ≤ PC < TE) DS ≤ MAB < DE (2) !(TS ≤ PC < TE) TS ≤ MAB < TE (3) violation WRITE_MEM == 1 TS ≤ MAB < TE (4) DMA_EN == 1 TS ≤ DMA_ADDR < TE (5) DMA_EN == 1 DS ≤ DMA_ADDR < DE (6) TS: Text Section Start Add TE: Text Section End Add DS: Data Section Start Add DE: Data Section End Add

Seminara (KTH) DMA Support for the Sancus Architecture 19 February 2019 22 / 27

slide-27
SLIDE 27

Extending DMA on Sancus Exclude DMA from Protected Memory

3) Exclude DMA from Protected Memory

Pros

  • Allows DMA in the system,

preventing accesses to protected memory (SMs integrity and confidentiality preserved)

  • Reuse the already instantiated

MAL registers TS, TE, DS and DE

  • No software overhead or SMs

direct intervention required Cons

  • Solely allows DMA operations on

unprotected memory. Does not really extend SMs functionalities

Seminara (KTH) DMA Support for the Sancus Architecture 19 February 2019 22 / 27

slide-28
SLIDE 28

Extending DMA on Sancus Exclude DMA from Protected Memory

3) Exclude DMA from Protected Memory

MAL Circuit for a Single Software Module

Inputs Registers Output pc ≥ TS < = prev_pc ≥ TE < mab ≥ violation mb_en EN < mb_wr DS ≥ DE < ≥ dma_addr < dma_violation ≥ ≤ dma_en

Seminara (KTH) DMA Support for the Sancus Architecture 19 February 2019 22 / 27

slide-29
SLIDE 29

Extending DMA on Sancus DMA Confined Access to Protected Memory

4) Allow Access to Specific Locations inside SMs Data Sections

Enhances SMs functionalities with DMA capabilities, by relaxing integrity and confidentiality guarantees for a specific subset of the data section

Unprotected Entry point Code & constants Unprotected SM1 text section Protected Data DMA-allowed range Protected Data Unprotected SM1 data section Memory TS1 TE1 DS1

DMA_PS1 DMA_PE1 DE1

KN,SP,SM1 IDSM1 TSn TEn DSn

DMA_PSn DMA_PEn DEn

KN,SP,SMn IDSMn Next ID Caller ID KN SM1 metadata SMn metadata Layout Key ID Protected storage area Node

Seminara (KTH) DMA Support for the Sancus Architecture 19 February 2019 23 / 27

slide-30
SLIDE 30

Extending DMA on Sancus DMA Confined Access to Protected Memory

4) Allow Access to Specific Locations inside SMs Data Sections

PC != TS TS ≤ PC < TE !(TS ≤ PREV_PC < TE) (1) !(TS ≤ PC < TE) DS ≤ MAB < DE (2) !(TS ≤ PC < TE) TS ≤ MAB < TE (3) violation WRITE_MEM == 1 TS ≤ MAB < TE (4) DMA_EN == 1 DS ≤ DMA_ADDR < DE

!(DMA_PS ≤ DMA_ADDR < DMA_PE)

(5) DMA_EN == 1 TS ≤ DMA_ADDR < TE (6) TS: Text Section Start Add TE: Text Section End Add DS: Data Section Start Add DE: Data Section End Add DMA_PS: DMA Protected Start DMA_PE: DMA Protected End

Seminara (KTH) DMA Support for the Sancus Architecture 19 February 2019 23 / 27

slide-31
SLIDE 31

Extending DMA on Sancus DMA Confined Access to Protected Memory

4) Allow Access to Specific Locations inside SMs Data Sections

Pros

  • Allows DMA in the system,

preserviung SMs integrity and confidentiality

  • Reuse of the already instantiated

MAL registers TS, TE, DS and DE

  • Full configurability of the system

Cons

  • Extension of the ISA with a new

instruction to set the boundaries of the DMA-allowed subset

  • Register overhead: two extra

registers for each SM

  • Implicit trustworthiness of all the

DMA peripherals: currently impossible to selectively provide peripherals with access to protected memory

Seminara (KTH) DMA Support for the Sancus Architecture 19 February 2019 23 / 27

slide-32
SLIDE 32

Extending DMA on Sancus DMA Confined Access to Protected Memory

Reduce Register Overhead

4.1) Fix the start or the end addresses of the DMA-allowed subset Pros

  • Register overhead is halved,

since only the loose boundary has to be stored Cons

  • Reduced system flexibility in

positioning the subset inside the data section

Seminara (KTH) DMA Support for the Sancus Architecture 19 February 2019 24 / 27

slide-33
SLIDE 33

Extending DMA on Sancus DMA Confined Access to Protected Memory

Reduce Register Overhead

4.2) Allow only one DMA-allowed subset per time Pros

  • Register overhead is dramatically

reduced Cons

  • No direct data transfer between

two SMs with DMA

  • Software overhead, as each SM

must load the boundaries of its DMA allowed memory subset before any DMA operation

Seminara (KTH) DMA Support for the Sancus Architecture 19 February 2019 24 / 27

slide-34
SLIDE 34

Attack Scenario

// ============================ // ENABLE SMs PROTECTION | // ============================ .... SM with ID 2 enabled: 0x7588 0x78c2 0x02aa 0x03b4 .... // ============================ // START THE ATTACK | // ============================ [attacker] Reading into SM2 text section ... [attacker] Num. of Words: 6 Data0 at addr. 0x7588: 0xc232 Data1 at addr. 0x758a: 0x4182 Data2 at addr. 0x758c: 0x03b0 Data3 at addr. 0x758e: 0x40b2 Data4 at addr. 0x7590: 0x03ac Data5 at addr. 0x7592: 0x03b2 [attacker] Writing into SM2 text section ... [attacker] Num. of Words: 6 ... [attacker] Reading into SM2 text section after having written ... [attacker] Num. of Words: 6 Data0 at addr. 0x7588: 0x0000 Data1 at addr. 0x758a: 0x0001 Data2 at addr. 0x758c: 0x0002 Data3 at addr. 0x758e: 0x0003 Data4 at addr. 0x7590: 0x0004 Data5 at addr. 0x7592: 0x0005 // ============================ // SIMULATION PASSED | // ============================ // ============================ // ENABLE SMs PROTECTION | // ============================ .... SM with ID 2 enabled: 0x7588 0x78c2 0x02aa 0x03b4 .... // ============================ // START THE ATTACK | // ============================ [attacker] Reading into SM2 text section ... [attacker] Num. of Words: 6

  • -> Illegal
  • mem. access

detected! Data0 at addr. 0x7588: 0x0000 Data1 at addr. 0x758a: 0x0000 Data2 at addr. 0x758c: 0x0000 Data3 at addr. 0x758e: 0x0000 Data4 at addr. 0x7590: 0x0000 Data5 at addr. 0x7592: 0x0000 [attacker] Writing into SM2 text section ... [attacker] Num. of Words: 6

  • -> Illegal
  • mem. access

detected! [attacker] Reading into SM2 text section after having written ... [attacker] Num. of Words: 6

  • -> Illegal
  • mem. access

detected! Data0 at addr. 0x7588: 0x0000 Data1 at addr. 0x758a: 0x0000 Data2 at addr. 0x758c: 0x0000 Data3 at addr. 0x758e: 0x0000 Data4 at addr. 0x7590: 0x0000 Data5 at addr. 0x7592: 0x0000 // ============================ // SIMULATION PASSED | // ============================

Seminara (KTH) DMA Support for the Sancus Architecture 19 February 2019 25 / 27

slide-35
SLIDE 35

Open Problems

Open Problems

– Rowhammer: DMA widens the threats of Rowhammer attacks by allowing to repeatedly access specific memory locations without any CPU involvement – Side Channel Attacks: DMA support inclusion extends the side channel attack base.

Seminara (KTH) DMA Support for the Sancus Architecture 19 February 2019 26 / 27

slide-36
SLIDE 36

Conclusions and Future Work

Conclusions and Future Work Conclusions

The disruptive outcomes of direct DMA implementation prompt the need of providing secure DMA support. Suitable solutions are to totally exclude DMA from protected memory, or to relax securities guarantees and allow DMA in specific protected memory locations

Future Work

Implement and investigate the theoretical solution that allows DMA in confined memory subsets of SMs data sections Include the DMA controller in the TCB, allowing it to: Introduce the concept of trusted peripherals IDs Selectively grant access to DMA interface Store private informations, like the identity or the ID, of the party that started a DMA operation

Seminara (KTH) DMA Support for the Sancus Architecture 19 February 2019 27 / 27

slide-37
SLIDE 37

References

References I

Pieter Agten, Raoul Strackx, Bart Jacobs, and Frank Piessens. Secure compilation to modern processors, 2012. Victor Costan and Srinivas Devadas. Intel sgx explained. Cryptology ePrint Archive, Report 2016/086, 2016. Dmitry Evtyushkin, Jesse Elwell, Meltem Ozsoy, Dmitry Ponomarev, Nael Abu Ghazaleh, and Ryan Riley. Iso-x: A flexible architecture for hardware-managed isolated execution. In Proceedings of the 47th Annual IEEE/ACM International Symposium on Microarchitecture, MICRO-47, pages 190–202, Washington, DC, USA, 2014. IEEE Computer Society. Jonathan M. McCune, Bryan J. Parno, Adrian Perrig, Michael K. Reiter, and Hiroshi Isozaki. Flicker: An execution infrastructure for tcb minimization. In Proceedings of the 3rd ACM SIGOPS/EuroSys European Conference on Computer Systems 2008, Eurosys ’08, pages 315–328, New York, NY, USA, 2008. ACM.

Seminara (KTH) DMA Support for the Sancus Architecture 19 February 2019 1 / 10

slide-38
SLIDE 38

References

References II

Job Noorman, Jo Van Bulck, Jan Tobias Mühlberg, Frank Piessens, Pieter Maene, Bart Preneel, Ingrid Verbauwhede, Johannes Götzfried, Tilo Müller, and Felix Freiling. Sancus 2.0: A low-cost security architecture for iot devices. ACM Transactions on Privacy and Security (TOPS), 20(3):7:1–7:33, September 2017. Marco Patrignani, Pieter Agten, Raoul Strackx, Bart Jacobs, Dave Clarke, and Frank Piessens. Secure compilation to protected module architectures. ACM Trans. Program. Lang. Syst., 37(2):6:1–6:50, April 2015.

Seminara (KTH) DMA Support for the Sancus Architecture 19 February 2019 2 / 10

slide-39
SLIDE 39

Security Solutions Review

Solutions on High-End Devices

1 Use of hardware support for virtual memory in combination with

processor privilege levels.

2 Use of a memory-safe virtual machine equipped with a VM guard Seminara (KTH) DMA Support for the Sancus Architecture 19 February 2019 3 / 10

slide-40
SLIDE 40

Security Solutions Review

Solutions on High-End Devices

1 Use of hardware support for virtual memory in combination with

processor privilege levels.

2 Use of a memory-safe virtual machine equipped with a VM guard Seminara (KTH) DMA Support for the Sancus Architecture 19 February 2019 3 / 10

slide-41
SLIDE 41

Security Solutions Review

Disadvantages of Classical Solutions

1 Non-trivial support for remote attestation2 2 Expensive to implement → non compatible with lightweight

embedded devices

3 Rely on a software layer – OS or hypervisor → Do not protect from

system-level attacks. Watch out A tampered with OS allows attackers to fully manipulate the software, breaking the root of trust need for hardware-based solutions.

2Remote attestation is a property of a system which a remote stakeholder relies on to

verify that a specific software module is running untampered on a remote device.

Seminara (KTH) DMA Support for the Sancus Architecture 19 February 2019 4 / 10

slide-42
SLIDE 42

PC Based Memory Access Control

Program-Counter Based Memory Access Control

PC Based MAC Memory protection technique which sets different memory permissions depending on the current value of the PC.

Memory access rights PC from \ to Protected Unprotected Entry point Code Data Entry point r - x r - x r w - r w x Text section r - x r - x r w - r w x Unprotected \ Other SMs

  • - x
  • - -
  • - -

r w x

Seminara (KTH) DMA Support for the Sancus Architecture 19 February 2019 5 / 10

slide-43
SLIDE 43

PC Based Memory Access Control

Program-Counter Based Memory Access Control

Hardware-only solution, with minimal TCB3 Strong modules isolation and confidentiality guarantees Low cost → compatible with lightweight embedded devices Preserves isolation of compiled code from modern programming languages (C++, Java, etc...) [1, 6]

Memory access rights PC from \ to Protected Unprotected Entry point Code Data Entry point r - x r - x r w - r w x Text section r - x r - x r w - r w x Unprotected \ Other SMs

  • - x
  • - -
  • - -

r w x

3Trusted Computing Base Seminara (KTH) DMA Support for the Sancus Architecture 19 February 2019 5 / 10

slide-44
SLIDE 44

PC Based Memory Access Control

Program-Counter Based Memory Access Control

Hardware-only solution, with minimal TCB Strong modules isolation and confidentiality guarantees Low cost → compatible with lightweight embedded devices Preserves isolation of compiled code from modern programming languages (C++, Java, etc...) [1, 6]

***Java code*** public class Foo{ private int secret = 0; public void add() { this.secret += 1; } } ***C code*** typedef struct foo_t { int secret = 0; void (*add)(struct Foo*, int) = add_f; } Foo; void add_f(Foo* a, int amount) { a → secret += 1; return; } leaked_secret = *(Foo_ptr+sizeof(int)) Seminara (KTH) DMA Support for the Sancus Architecture 19 February 2019 5 / 10

slide-45
SLIDE 45

Sancus Full System Overview

Sancus Extended System View

Register File ALU

Execution Unit MAL Layout Key SM1 SM control MAL Layout Key SM2

CPU Core Memory Backbone

Spongent SpongeWrap Crypto Unit Node key

RAM

  • r

ROM RAM

Peripherals

Frontend

PC MAB MAB Violation Key & Layout Data Registers Registers Violation

Address registers

DMA Controller

Number of words

FSM

MMIO DMA Device

Configuration Register Start Address Read Data Write Data

Acknowledges Control Signals Data to Write Control Signals Read Data Control Signals DMA Address Data Out Peripheral Bus

Seminara (KTH) DMA Support for the Sancus Architecture 19 February 2019 6 / 10

slide-46
SLIDE 46

DMA Controller Arbitration Circuit

Arbitration Circuit

PRIORITY ENCODER DMA CONTROLLER

FSM

N

RQST RQST

N-1

RQST

1

RQST DMA Output Bus

DEVN-1 DEV1 DEVN

DMA Input Bus

Register

EN RST

log(N+1)

2

DEV0

DMA_ACK

1

DMA_ACK

N

DMA_ACK

N-1

DMA_ACK RQST DMA_ACK

log(N+1)

2

Seminara (KTH) DMA Support for the Sancus Architecture 19 February 2019 7 / 10

slide-47
SLIDE 47

DMA ASM Chart

RESET addr0_rst =1, count_rst = 1, dev_count_rst = 1, fifo_rst = 1, msp_count_rst = 1,

  • ld_addr_rst = 1,

reset_rqst_reg = 1, words_rst = 1 IDLE addr0_rst = 1, count_rst = 1, dev_count_rst = 1, fifo_rst = 1, get_rsqt = 1, msp_count_rst = 1, words_rst = 1 RQST GET_REGS addr0_reg_en = 1, mmio_add_en = 1, word_reg_en = 1 MMIO_OP RD_WR LOAD_DMA_ADD dma_en = 1, count_en = 1 & dma_ready, drive_dma_addr = 1, fifo_wr_rd = 1 DMA_ READY READ_MEM count_en = 1, dma_en = 1, drive_dma_addr = 1, fifo_en = 1, fifo_wr_rd = 1,

  • ld_add_reg_en = 1

DMA_RESP FIFO_FULL FIFO_FULL _READ FLAG_CNT_ WORDS_RD ERROR error_flag = 1 drive_dma_addr = 1 fifo_rst = 1 IDLE DMA_READY OLD_ADDR_RD dma_en = 1, drive_dma_addr = 1, fifo_old_add_flag = 1, fifo_wr_rd = 1, mux = 1 MMIO_OP SEND_TO_MEM0 SEND_TO_DEV0 count_rst = 1, DEV_ACK WAIT_READ SEND_TO_DEV1 dma_ack = 1, count_en = 1, fifo_en = 1 FLAG_CNT_ WORDS END_READ end_flag = 1 DEV_ACK NOP IDLE READ_DEV0 fifo_wr_rd = 1,

  • ut_to_msp = 1

DEV_ACK READ_DEV1 dma_ack = 1, count_en = 1, fifo_wr_rd = 1, fifo_en = 1,

  • ut_to_msp= 1

FLAG_CNT_ WORDS SEND_TO_MEM0 count_en = 1, count_load = 1, mmio_ff_en =1,

  • ut_to_msp= 1,

dma_we = "11" DEV_ACK WAIT_WRITE fifo_wr_rd = 1,

  • ut_to_msp= 1

FIFO_FULL SEND_TO_MEM1 count_en = 1, dma_en = 1, dma_we = "11", drive_dma_addr = 1, fifo_en = 1,

  • ld_addr_reg_en = 1,
  • ut_to_msp = 1

DMA_RESP ERROR DMA_READY OLD_ADDR_WR dma_en = 1, dma_we = "11", drive_dma_addr = 1, fifo_en = 1, fifo_old_addr_flag = 1, mux = 1,

  • ut_to_msp = 1

FLAG_CNT_ WORDS END_WRITE dma_drive_addr = 1, end_flag = 1,

  • ut_to_msp= 1

IDLE FIFO_FULL_WR 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

Seminara (KTH) DMA Support for the Sancus Architecture 19 February 2019 8 / 10

slide-48
SLIDE 48

DMA ASM Chart

FIFO_FULL_READ MMIO_OP FIFO_FULL_RD count_en = 1, count_load = 1, load_dev_or_msp = 1 WAIT_DEV DEV_ACK EMPTY_FIFO_READ dma_ack = 1, fifo_en = 1 FIFO_EMPTY_ PARTIAL RESTORE_MSP_COUNT count_en = 1, count_load = 1, dev_count_reg_en_f = 1 READ_MEM FIFO_FULL_WR count_load = 1, dma_we = "11", drive_dma_addr = 1,

  • ut_to_msp= 1

EMPTY_FIFO_WRITE count_en = 1, dma_en = 1, dma_we = "11", drive_dma_addr = 1, fifo_en = 1,

  • ld_addr_reg_en = 1,
  • ut_to_msp = 1

DMA_RESP ERROR DMA_READY FIFO_EMPTY_ PARTIAL MMIO_OP RESTORE_MSP_COUNT RESTORE_DEV_COUNT count_en = 1, count_load = 1, msp_count_reg_en = 1, restore_dev_or_msp = 1 READ_DEV1 OLD_ADDR_EMP_FIFO_WR dma_en = 1, dma_we = "11", drive_dma_addr = 1, fifo_en = 1, fifo_old_addr_flag = 1, mux_old_addr = 1,

  • ut_to_msp = 1

DEFAULT SIGNALS addr_reg_en = 0, addr0_rst = 0, count_en = 0, count_rst = 0, dev_count_reg_en_f = 0, dev_count_rst = 0, dma_ack = 0, dma_en = 0, dma_priority = 0, dma_we = "00", drive_dma_addr = 0, end_flag = 0, error_flag = 0, fifo_en = 0, fifo_old_add_flag = 1, fifo_rst = 0, fifo_wr_rd = 0, get_rsqt = 0, load_dev_or_msp = 0, mmio_add_en = 0, mmio_add_rst = 0, mmio_ff_en = 0, mmio_ff_rst = 0, msp_count_reg_en_f = 0, msp_count_rst = 0, mux_old_addr = 0,

  • ld_add_reg_en = 0,
  • ld_addr_rst = 0,
  • ut_to_msp = 0,

reset_rqst_reg = 0, words_reg_en = 0, words_rst = 0 1 1 1 1 1 1 1

Seminara (KTH) DMA Support for the Sancus Architecture 19 February 2019 8 / 10

slide-49
SLIDE 49

DMA Protocol

DMA Protocol for Read/Write Operations

Timing diagram for a read operation Timing diagram for a write operation

Seminara (KTH) DMA Support for the Sancus Architecture 19 February 2019 9 / 10

slide-50
SLIDE 50

Intel SGX Protection Mechanism

Detail of Intel SGX Processor Reserved Memory (PRM)

DRAM PRM PRM EPC Enclave Page Cache 4kb page 4kb page 4kb page 4kb page Entry Entry Entry Entry Enclave Page Cache Map

In Intel SGX [2] (or Iso-X [3]) the equivalent of modules protected sections are stored in a specific range of the memory. Hence, the protection mechanism consists in denying every DMA accesses to those regions.

Seminara (KTH) DMA Support for the Sancus Architecture 19 February 2019 10 / 10