From ffc448a9b7fe1ebc1edc47bc8b4da361cb264f2b Mon Sep 17 00:00:00 2001 From: Iru Cai Date: Tue, 28 May 2019 18:38:53 +0800 Subject: fixes --- chap/chap1.tex | 9 ++++----- chap/chap2.tex | 8 ++++---- chap/chap3.tex | 40 ++++++++++++++++++++-------------------- chap/chap4.tex | 54 ++++++++++++++++++++++++++---------------------------- thesis.bib | 6 ++++++ 5 files changed, 60 insertions(+), 57 deletions(-) diff --git a/chap/chap1.tex b/chap/chap1.tex index 5a3224d..e6a55b0 100644 --- a/chap/chap1.tex +++ b/chap/chap1.tex @@ -42,12 +42,11 @@ Tomasulo 算法\supercite{tomasulo},可以识别指令之间的依赖关系, \begin{figure}[htbp] \centering \includegraphics[width=0.8\textwidth]{skylake.pdf} - \caption{Skylake 微体系结构示意图} + \caption{Skylake 微体系结构示意图\supercite{mdsattack}} \label{fig:skylake} \end{figure} -图\ref{fig:skylake}是 Intel Skylake 微体系结构的示意图\footnote{图片来 - 自 https://mdsattacks.com/images/skylake.svg},它是一个乱序执行超标 +图\ref{fig:skylake}是 Intel Skylake 微体系结构的示意图,它是一个乱序执行超标 量处理器体系结构,每周期最多可以将 6 个微操作发射至 8 组执行单元中执行, 它的 ROB 使得流水线中可以同时存在 224 个微操作,它的分支预测器可以预测 分支的方向和目标地址,使处理器在预测的目标处取出指令至指令缓存。 @@ -69,7 +68,8 @@ Microsoft 等软件厂商,均发布了软件补丁或处理器微码更新, 了部分已有的软件和微码防御方法,它们所防御的攻击,和造成的性能损失。 \supercite{systematic} -\begin{table}[htbp] +\begin{table}[hptb] + \caption{软件防御对性能的影响} \begin{tabular}{ccc} \hline 防御方法 & 防御的攻击种类 & 性能损失\tabularnewline @@ -83,7 +83,6 @@ Microsoft 等软件厂商,均发布了软件补丁或处理器微码更新, \hline \end{tabular} \centering - \caption{软件防御对性能的影响} \label{tab:perf_mitigation} \end{table} diff --git a/chap/chap2.tex b/chap/chap2.tex index a1719ca..52d5410 100644 --- a/chap/chap2.tex +++ b/chap/chap2.tex @@ -1,7 +1,7 @@ % Copyright (c) 2014,2016 Casper Ti. Vector % Public domain. -\chapter{Meltdown 和 Spectre攻击}\label{sec:attack} +\chapter{Meltdown 和 Spectre 攻击与分析}\label{sec:attack} 本章首先介绍侧信道攻击,之后对已有的 Meltdown 和 Spectre 攻击的各种变 体进行分类讲解,最后简单地介绍已有攻击的其他使用形式。 @@ -116,7 +116,7 @@ Intel 处理器,也可能可用于其他厂商的处理器。 态指令序列可以将读取到的数据通过隐蔽信道发送给攻击者。 \begin{figure} - \centering +\centering \begin{minted}{nasm} xor rax, rax retry: @@ -199,7 +199,7 @@ SGX 处理器无法保证隔离区的数据保密性,也无法证明隔离区 % foreshadow attack \begin{figure}[htbp] \centering - \includegraphics[width=0.8\textwidth]{addr-trans.eps} + \includegraphics[width=0.6\textwidth]{addr-trans.eps} \caption{地址翻译过程和 L1 终端错误的原理\supercite{foreshadowNG}} \label{fig:addr-tran} \end{figure} @@ -448,7 +448,7 @@ if (x < array1_size) 处理器读取 array1 数组外的敏感内容。否则,越界的数组下标 x 可能触发异 常,也可以通过构造 x 用于访问敏感数据。 -\begin{figure}[htbp] +\begin{figure}[!htbp] \centering \includegraphics[width=0.4\textwidth]{spectre_v1.eps} \caption{边界检查结果和分支预测方向的可能情形\supercite{spectre}} diff --git a/chap/chap3.tex b/chap/chap3.tex index a5fe00c..68baf93 100644 --- a/chap/chap3.tex +++ b/chap/chap3.tex @@ -1,9 +1,9 @@ -\chapter{Meltdown 和 Spectre 攻击的防御方案及分析}\label{sec:defense} +\chapter{Meltdown 和 Spectre 防御方法与分析}\label{sec:defense} Meltdown 和 Spectre 及其多种变体被发现后,研究者提出了多种减轻这些攻击 的软硬件防御方法。本章讨论并分析已有的防御方法。 -\section{Meltdown型攻击的防御} +\section{Meltdown 型攻击的防御} Meltdown 型攻击利用了暂态指令可以读取体系结构层次上不可访问的数据,并且 用此数据做计算。因此一种防御方式是使体系结构层次上不可访问的数据,在微 @@ -17,7 +17,7 @@ Meltdown 攻击的方案。它的作用是在用户空间中去除内核空间 新的 Linux 内核在上下文切换时,对所有进程都会保存和恢复浮点寄存器,从 而用户程序使用浮点寄存器都不会产生异常,从而消除这种攻击。 -\section{Spectre型攻击的防御} +\section{Spectre 型攻击的防御} Spectre 型攻击的防御方案可以分为三类:阻止推测式执行、防止暂态指令访问 秘密数据、切断隐蔽信道或降低隐蔽信道的精度。研究者在软件和硬件方面都提 @@ -70,8 +70,8 @@ retpoline\supercite{retpoline} 是 Google 提出的防御 Spectre-BTB 的方法 Webkit 在数组访问中使用索引掩码(index masking)\supercite{webkit} 方 法,它让数组下标和一个值进行与操作,去掉下标高位的1,将数组下标控制在 一定范围内,防止处理器在推测式执行中访问数组指定范围之外的数据。Linux -构造了一个粒度更细的 array\_index\_nospec \supercite{linux-spec},它的 -功能如图\ref{fig:array-index-nospec}: +使用了一个粒度更细的索引掩码\supercite{linux-spec}, +它的功能如图 \ref{fig:array-index-nospec} 中代码所示: \begin{figure}[htbp] \centering @@ -206,7 +206,8 @@ Spectre 等攻击由暂态指令引起,为了定义 InvisiSpec 的攻击模型 源。根据这两类攻击,InvisiSpec 设计了两种模型模 型:Spectre 和 Futuristic. -\begin{table} +\begin{table}[htbp] +\caption{暂态指令的来源} \begin{tabular}{|c|c|} \hline 攻击 & 暂态指令的来源\tabularnewline @@ -227,7 +228,6 @@ Speculative Store Bypass & 装载指令和更早的存储指令地址别名\tabu 未来的攻击 & 异常、控制流预测错误、访存别名、一致性违例、中断等\tabularnewline \hline \end{tabular} -\caption{暂态指令的来源} \label{tab:transient_insn} \centering \end{table} @@ -504,20 +504,20 @@ CSF 由以下几个关键部件组成: \item 错误训练防御:用于保护分支预测器、返回地址栈等部件 \end{enumerate} -\begin{table} - \centering +\begin{table}[htbp] +\centering +\caption{CSF 新定义的三种 fence} \begin{tabular}{cccccc} \hline fence & 作用位置 & 严格/宽松 & 不允许的指令 & 防御的攻击种类\tabularnewline \hline LSQ-LFENCE & LSQ & 宽松 & 装载 & v1\tabularnewline -\hline +%\hline LSQ-MFENCE & LSQ & 宽松 & 装载和存储 & v1,v1.1,v1.2\tabularnewline -\hline +%\hline CFENCE & 缓存控制器 & 宽松 & 无 & v1\tabularnewline \hline \end{tabular} -\caption{CSF 新定义的三种 fence} \label{tab:csffence} \centering \end{table} @@ -557,23 +557,23 @@ fence 操作的设计上有以下考虑: 存信道,如果指令 $j$ 不修改缓存的内容,则它对于缓存信道不具有安全依赖, 尽管它可能会通过其他信道泄露某些信息。 -\begin{table} - \centering -\begin{tabular}{|c|c|c|} +\begin{table}[htbp] +\centering +\caption{Spectre 攻击中的安全依赖} +\begin{tabular}{ccc} \hline Spectre 变体 & 指令 $i$ & 指令 $j$\tabularnewline \hline -\hline +%\hline Spectre v1 & 条件分支 & 访存\tabularnewline -\hline +%\hline Spectre v2 & 间接转移 & 访存\tabularnewline -\hline +%\hline Spectre v4 & 访存 & 访存\tabularnewline -\hline +%\hline SpectrePrime & 条件分支 & 访存\tabularnewline \hline \end{tabular} -\caption{Spectre 攻击中的安全依赖} \label{tab:secdep} \centering \end{table} diff --git a/chap/chap4.tex b/chap/chap4.tex index b816540..38ad65d 100644 --- a/chap/chap4.tex +++ b/chap/chap4.tex @@ -85,6 +85,7 @@ DIFT 可以作为 Spectre 攻击的检测手段之一。Spectre 的论文中指 据的标记均为0,为了描述方便,这里用体系结构寄存器进行描述,实际的微处理器中,数据可存放在物理寄存器、保留站、ROB等结构。 \begin{table} +\caption{分支中代码产生的 DIFT 行为} \begin{tabular}{|c|c|c|} \hline 指令 & 指令的语义 & DIFT 行为\tabularnewline @@ -107,7 +108,6 @@ lea rdx, {[}rip + 0x2b425d{]} & rdx <- rip + 0x2b425d & T{[}rdx{]} <- T{[}rip{]} & & T{[}rax{]} <- 1\tabularnewline \hline \end{tabular} -\caption{分支中代码产生的 DIFT 行为} \label{tab:spectre_dift} \centering \end{table} @@ -326,56 +326,54 @@ InvisiSpec 中,一级缓存处理 SpecLoad 和 Expose 的部分状态如 为了维护指令的安全、推测式内存读取等信息,需要在 DynInst 类为指令添加 新的状态和属性,添加的主要的指令状态和属性见表\ref{tab:inst_status}。 -\begin{table} -\begin{tabular}{|p{0.25\textwidth}|p{0.75\textwidth}|} +在每一周期,更新流水线中每条指令的 PrevBrsResolved 状态。在 LSQ 中,对于每一个未完成的装载指令,根据指令 +之前是否存在未决分支,判断指令是否安全,设定 ReadyToExpose 属性,取消 FenceDelay 标志。 + +执行单元执行一条装载指令时,根据 ReadyToExpose 属性判断是否需要用 +InvisiSpec 等安全的方式执行。修改后的执行流程如图 \ref{fig:is-load}, +LSQ 每周期都要将已转为安全指令的装载指令的验证或曝光,发送请求的 +LSQUnit::read 过程需要支持 SpecLoad 请求的发送,对地址翻译的过程做一个 +微小的修改,对 TLB 不命中的推测式执行的指令要延迟执行,防止产生 TLB 的 +侧信道。 + +\begin{table}[htbp] +\centering +\caption{新增的指令状态} +\begin{tabular}{p{0.25\textwidth}p{0.75\textwidth}} \hline 指令状态和属性 & 含义\tabularnewline \hline -\hline +%\hline PrevBrsResolved & 记录指令之前的分支是否得出结果\tabularnewline -\hline +%\hline IsTainted & 在基于 DIFT 的检测方案中,记录指令是否依赖于被标记的寄存器\tabularnewline -\hline +%\hline AfterTaintedBranch & 在基于 DIFT 的检测方案中,记录指令是否在被标记的转 移指令之后\tabularnewline -\hline +%\hline L1Hit & 记录指令的 SpecLoad 请求是否命中一级缓存并且缓存内容不变,如果 是,则不需要发送验证请求\tabularnewline -\hline +%\hline ExposeSent & 已发送 Expose 请求\tabularnewline -\hline +%\hline ExposeCompleted & Expose 已执行完成\tabularnewline -\hline +%\hline ValidationCompleted & 数据已验证完成\tabularnewline -\hline +%\hline NeedPostFetch & 需要再次发送 Expose 请求\tabularnewline -\hline +%\hline ReadyToExpose & 指令已确认安全,可以发送 Expose 请求,或直接用基本的方 式执行指令\tabularnewline -\hline +%\hline NeedExposeOnly & 只需要发送 Expose,而不需要通过再次读取数据用于验证\tabularnewline -\hline +%\hline FenceDelay & 指令被阻止执行,直到确认安全,在 InvisiSpec 之外的执行方 案中使用\tabularnewline \hline \end{tabular} -\caption{新增的指令状态} \label{tab:inst_status} -\centering \end{table} -在每一周期,处理器扫描 ROB 中的每条指令,更新流水线中每条指令的 -PrevBrsResolved 状态。在 LSQ 中,对于每一个未完成的装载指令,根据指令 -之前是否存在未决分支,判断指令是否安全,设定 ReadyToExpose 属性,取消 -FenceDelay 标志。 - -执行单元执行一条装载指令时,根据 ReadyToExpose 属性判断是否需要用 -InvisiSpec 等安全的方式执行。修改后的执行流程如图 \ref{fig:is-load}, -LSQ 每周期都要将已转为安全指令的装载指令的验证或曝光,发送请求的 -LSQUnit::read 过程需要支持 SpecLoad 请求的发送,对地址翻译的过程做一个 -微小的修改,对 TLB 不命中的推测式执行的指令要延迟执行,防止产生 TLB 的 -侧信道。 - \begin{figure}[htbp] \centering \includegraphics[width=0.6\textwidth]{is-load.eps} diff --git a/thesis.bib b/thesis.bib index 8e6929a..5dafd07 100644 --- a/thesis.bib +++ b/thesis.bib @@ -865,4 +865,10 @@ This thesis highlights two aspects of the BOOM design: its industry-competitive type={C}, } +@online{mdsattack, + title = {RIDL and Fallout: MDS attacks}, + year = {2019}, + type = {OL}, + url = {https://mdsattacks.com/}, +} % vim:ts=4:sw=4 -- cgit v1.2.3