From 48ba0474d11608869717c7bc1a9b9fe4e1196977 Mon Sep 17 00:00:00 2001 From: Iru Cai Date: Sat, 11 May 2019 23:09:45 +0800 Subject: add tables --- chap/chap2.tex | 7 +++++-- chap/chap4.tex | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ thesis.tex | 2 ++ 3 files changed, 56 insertions(+), 2 deletions(-) diff --git a/chap/chap2.tex b/chap/chap2.tex index 0366d03..3224d22 100644 --- a/chap/chap2.tex +++ b/chap/chap2.tex @@ -477,11 +477,14 @@ Spectre-PHT 利用分支预测器,攻击者可以训练转移预测器,使 Spectre v1 是最早提出的 Spectre 攻击,属于 Spectre-PHT 类型。它利用受 害者程序中的分支,一个例子如下: -\begin{minted}{C} +\begin{figure}[htbp] +\begin{minted}[frame=single,linenos=true]{C} if (x < array1_size) y = array2[array1[x] * 4096]; \end{minted} - +\caption{Spectre v1 受害者代码} +\label{lst:spectre_v1} +\end{figure} %%%%%%%%%%%%%%%%%%%%%%% gtran: spectre v1 %%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/chap/chap4.tex b/chap/chap4.tex index 455e2b6..6c058f1 100644 --- a/chap/chap4.tex +++ b/chap/chap4.tex @@ -37,6 +37,55 @@ CSF\supercite{context-sensitive-fencing} 中的译码级信息流追踪框架 DI 断是否需要插入 fence 微码。OISA\supercite{oisa} 在指令系统的定义中即包 含了 DIFT 技术,用于追踪一个数据是否为秘密数据。 +以图\ref{lst:spectre_v1}的 Spectre v1 组件代码为例,这段代码产生 +图\ref{lst:spectre_v1_asm}所示的指令。 + +\begin{figure}[htbp] +\begin{minted}[frame=single,linenos=true]{nasm} + xor eax, eax + cmp qword [rip + 0x2b157f], rdi + jbe loc.funcret + lea rax, [rip + 0x2b14ae] + add rax, rdi + movzx eax, byte [rax] + shl eax, 12 + lea rdx, [rip + 0x2b425d] + mov eax, dword [rdx + rax] + loc.funcret: ret +\end{minted} +\caption{Spectre 组件的汇编代码} +\label{lst:spectre_v1_asm} +\end{figure} + +这些指令中,在分支后执行的指令,DIFT 的行为如表\ref{tab:spectre_dift}所示。 + +\begin{table} +\begin{tabular}{|c|c|c|} +\hline +指令 & 指令的语义 & DIFT 行为\tabularnewline +\hline +\hline +lea rax, {[}rip + 0x2b14ae{]} & rax <- rip + 0x2b14ae & T{[}rax{]} <- T{[}rip{]} = 0\tabularnewline +\hline +add rax, rdi & rax <- rax + rdi & T{[}rax{]} <- T{[}rax{]} | T{[}rdi{]} = 0\tabularnewline +\hline +\multirow{2}{*}{movzx eax, byte {[}rax{]}} & \multirow{2}{*}{eax <- (uint8\_t){[}eax{]}} & T{[}rax{]} = 0, 指令安全\tabularnewline +\cline{3-3} + & & T{[}rax{]} <- 1\tabularnewline +\hline +shl eax, 12 & eax <- eax {*} 4096 & T{[}rax{]} <- T{[}rax{]} = 1\tabularnewline +\hline +lea rdx, {[}rip + 0x2b425d{]} & rdx <- rip + 0x2b425d & T{[}rdx{]} <- T{[}rip{]} = 0\tabularnewline +\hline +\multirow{2}{*}{eax, dword {[}rdx + rax{]}} & \multirow{2}{*}{eax <- {[}rdx + rax{]}} & (T{[}rdx{]} | T{[}rax{]}) = 1, 指令不安全 \tabularnewline +\cline{3-3} + & & T{[}rax{]} <- 1\tabularnewline +\hline +\end{tabular} +\caption{分支中代码产生的 DIFT 行为} +\label{tab:spectre_dift} +\end{table} + 本文使用 DIFT 检测 Spectre 组件中泄露数据的 load 指令。详细设计如下: \Todo: 解释为什么使用这种方法,和其他相似方法(DLIFT, TPBuf, SG(Full))的比较 diff --git a/thesis.tex b/thesis.tex index 722fb9a..3856d73 100644 --- a/thesis.tex +++ b/thesis.tex @@ -52,6 +52,8 @@ \newcommand{\Fault}[1]{\texttt{\#}#1} \newcommand{\Todo}{\textbf{TODO}} \newcommand{\Fixme}{\textbf{FIXME}} +\usepackage{caption} +\newenvironment{code}{\captionsetup{type=listing}}{} \begin{document} % 以下为正文之前的部分,默认不进行章节编号。 -- cgit v1.2.3