Intel嚴重漏洞 OS更新將會降低效能 - 3C
By Rosalind
at 2018-01-05T11:42
at 2018-01-05T11:42
Table of Contents
看了三天的 paper 終於看懂 Meltdown 怎麼做到的
Spectre 太複雜看不懂沒時間懶得看所以不談
首先我預設大家都知道
instruction-level paralleism 指令層級平行,
superscalar 超純量,
out-of-order execution 亂序執行,
speculative execution 推測執行
他們之間的關聯為,為了達成 ILP 所以引入 superscalar。
但是資料相依性問題造成 superscalar 不能很好發揮,因此
引入 out-of-order execution 讓 CPU 挑鄰近的可以同時執
行的指令執行。再來 speculative execution 遇到條件分支
conditional branch 時先預測會進某個分支並執行。
除此之外還有 micro op,以下寫作 uop,則是把一個 instr-
cution 拆成好幾個 uop 並把他丟下去跑。CPU 裡有好幾個不
同運算單元,包含算術運算、讀寫單元、分支單元,而且分別
都有複數分身可以同時執行。所以指令拆成 uop 以後先堆到
buffer 裡面,再丟到各個單元去跑。
把以上所有東西合起來就是,先解決資料相依性問題,挑幾個
鄰近的指令進來,拆成 uop,丟到 buffer,開始排程去跑,
並根據分支預測把可能的指令拿過來拆一拆一起下去跑。
接著 Meltdown 攻擊的問題點在於,當 user mode process
存取他不該存取的記憶體資料時,那個指令會產生一個例外
execption, 接著會產生一個中斷 interrupt 丟給 OS 去處理
這個例外。但因為以上幾個東西合在一起,其實指令的執行先
後順序是不一定的,有可能後面的跑一跑並且產生了一些副作
用,結果因為前面的指令產生例外,清空 buffer 與管線,雖
然暫存器 register 與記憶體都沒有寫入,理論上是當作沒發
生,可是卻有副作用發生了。這個副作用就是記憶體存取,會
先載入快取 cache。Layer 幾的快取其實不重要,因為重點是
它被載入快取中,所以存取時花費的時間一定比從記憶體存取
來的快。這個時間的差異就是洩漏出來的資訊。
考慮下面的指令
1 ; rcx = kernel address
2 ; rbx = probe array
3 retry:
4 mov al, byte [rcx]
5 shl rax, 0xc
6 jz retry
7 mov rbx, qword [rbx + rax]
在第四行會產生一個例外,但因為 OOOE 與推測執行,造成第
七行的讀取記憶體行為也執行了,它存取的資料被從記憶體中
搬入快取,但因為在第四行產生例外,因此 rbx 並沒有真的
被寫入資料。因為 rbx + rax 上的資料被移到快取了,它的
存取速度一定比其他在 probe array 裡的資料來的快,因此
只要掃一次整個 probe array 看看哪個資料存取速度比別的
快,再算出它與 probe array 起始位置的偏移量,就知道在
第四行中從 rcx 讀取到的 kernel data 是甚麼。
所以 KPTI 就是完全分離 kernel address 與 user address
,也就是 kernel space 的所有資料都不在 user space 中,
在 user space 讀資料都讀不到 kernel 資料,相對應的也不
會有例外產生。
--
--
Spectre 太複雜看不懂沒時間懶得看所以不談
首先我預設大家都知道
instruction-level paralleism 指令層級平行,
superscalar 超純量,
out-of-order execution 亂序執行,
speculative execution 推測執行
他們之間的關聯為,為了達成 ILP 所以引入 superscalar。
但是資料相依性問題造成 superscalar 不能很好發揮,因此
引入 out-of-order execution 讓 CPU 挑鄰近的可以同時執
行的指令執行。再來 speculative execution 遇到條件分支
conditional branch 時先預測會進某個分支並執行。
除此之外還有 micro op,以下寫作 uop,則是把一個 instr-
cution 拆成好幾個 uop 並把他丟下去跑。CPU 裡有好幾個不
同運算單元,包含算術運算、讀寫單元、分支單元,而且分別
都有複數分身可以同時執行。所以指令拆成 uop 以後先堆到
buffer 裡面,再丟到各個單元去跑。
把以上所有東西合起來就是,先解決資料相依性問題,挑幾個
鄰近的指令進來,拆成 uop,丟到 buffer,開始排程去跑,
並根據分支預測把可能的指令拿過來拆一拆一起下去跑。
接著 Meltdown 攻擊的問題點在於,當 user mode process
存取他不該存取的記憶體資料時,那個指令會產生一個例外
execption, 接著會產生一個中斷 interrupt 丟給 OS 去處理
這個例外。但因為以上幾個東西合在一起,其實指令的執行先
後順序是不一定的,有可能後面的跑一跑並且產生了一些副作
用,結果因為前面的指令產生例外,清空 buffer 與管線,雖
然暫存器 register 與記憶體都沒有寫入,理論上是當作沒發
生,可是卻有副作用發生了。這個副作用就是記憶體存取,會
先載入快取 cache。Layer 幾的快取其實不重要,因為重點是
它被載入快取中,所以存取時花費的時間一定比從記憶體存取
來的快。這個時間的差異就是洩漏出來的資訊。
考慮下面的指令
1 ; rcx = kernel address
2 ; rbx = probe array
3 retry:
4 mov al, byte [rcx]
5 shl rax, 0xc
6 jz retry
7 mov rbx, qword [rbx + rax]
在第四行會產生一個例外,但因為 OOOE 與推測執行,造成第
七行的讀取記憶體行為也執行了,它存取的資料被從記憶體中
搬入快取,但因為在第四行產生例外,因此 rbx 並沒有真的
被寫入資料。因為 rbx + rax 上的資料被移到快取了,它的
存取速度一定比其他在 probe array 裡的資料來的快,因此
只要掃一次整個 probe array 看看哪個資料存取速度比別的
快,再算出它與 probe array 起始位置的偏移量,就知道在
第四行中從 rcx 讀取到的 kernel data 是甚麼。
所以 KPTI 就是完全分離 kernel address 與 user address
,也就是 kernel space 的所有資料都不在 user space 中,
在 user space 讀資料都讀不到 kernel 資料,相對應的也不
會有例外產生。
--
→ eggimage:我之前也發生過很多次 yahoo本來就很爛 還外加奇摩12/10 18:52
推 madeinchina:之前即時通死都不讓我登入 後來我就改用MSN了...12/10 18:53
→ eggimage:發現MSN也不給你登....12/10 18:53
推 madeinchina: 就改登PTT了12/10 18:55
→ eggimage:最近ptt也一直斷....12/10 18:57
→ freely10469: 只好掀桌出去裸奔了...12/10 19:57
--
Tags:
3C
All Comments
By Mason
at 2018-01-07T08:18
at 2018-01-07T08:18
By James
at 2018-01-11T13:43
at 2018-01-11T13:43
By Carolina Franco
at 2018-01-15T12:39
at 2018-01-15T12:39
By Iris
at 2018-01-19T10:49
at 2018-01-19T10:49
By Caitlin
at 2018-01-21T22:42
at 2018-01-21T22:42
By Wallis
at 2018-01-25T15:32
at 2018-01-25T15:32
By Michael
at 2018-01-28T18:06
at 2018-01-28T18:06
By Quintina
at 2018-02-01T12:15
at 2018-02-01T12:15
By Xanthe
at 2018-02-03T21:44
at 2018-02-03T21:44
By Ivy
at 2018-02-05T16:08
at 2018-02-05T16:08
By Andrew
at 2018-02-06T00:11
at 2018-02-06T00:11
By Mia
at 2018-02-09T03:56
at 2018-02-09T03:56
By Oliver
at 2018-02-13T18:29
at 2018-02-13T18:29
By Irma
at 2018-02-18T08:45
at 2018-02-18T08:45
By Caroline
at 2018-02-22T14:43
at 2018-02-22T14:43
By Irma
at 2018-02-24T06:58
at 2018-02-24T06:58
By Jacob
at 2018-02-27T12:31
at 2018-02-27T12:31
By Doris
at 2018-02-27T22:12
at 2018-02-27T22:12
By Candice
at 2018-02-28T06:10
at 2018-02-28T06:10
By Charlie
at 2018-02-28T08:04
at 2018-02-28T08:04
By Christine
at 2018-03-01T19:14
at 2018-03-01T19:14
By Irma
at 2018-03-02T00:34
at 2018-03-02T00:34
By Ivy
at 2018-03-02T18:38
at 2018-03-02T18:38
By Daniel
at 2018-03-03T08:23
at 2018-03-03T08:23
By Joe
at 2018-03-03T17:15
at 2018-03-03T17:15
By Rachel
at 2018-03-06T16:42
at 2018-03-06T16:42
By Ophelia
at 2018-03-10T02:03
at 2018-03-10T02:03
By Rachel
at 2018-03-12T04:12
at 2018-03-12T04:12
By George
at 2018-03-12T10:07
at 2018-03-12T10:07
By Quintina
at 2018-03-14T06:12
at 2018-03-14T06:12
By Catherine
at 2018-03-15T17:13
at 2018-03-15T17:13
By Skylar Davis
at 2018-03-20T16:41
at 2018-03-20T16:41
By Callum
at 2018-03-21T08:58
at 2018-03-21T08:58
By Elvira
at 2018-03-24T15:09
at 2018-03-24T15:09
By Heather
at 2018-03-28T22:49
at 2018-03-28T22:49
By Blanche
at 2018-04-01T01:06
at 2018-04-01T01:06
By Necoo
at 2018-04-04T12:48
at 2018-04-04T12:48
By Charlotte
at 2018-04-09T12:37
at 2018-04-09T12:37
By John
at 2018-04-14T07:42
at 2018-04-14T07:42
By Zanna
at 2018-04-18T13:50
at 2018-04-18T13:50
By Lauren
at 2018-04-22T21:10
at 2018-04-22T21:10
By Yuri
at 2018-04-25T22:06
at 2018-04-25T22:06
By Dorothy
at 2018-04-30T07:06
at 2018-04-30T07:06
By Xanthe
at 2018-04-30T17:23
at 2018-04-30T17:23
By Necoo
at 2018-05-02T07:59
at 2018-05-02T07:59
By Adele
at 2018-05-04T23:27
at 2018-05-04T23:27
By Eden
at 2018-05-08T05:31
at 2018-05-08T05:31
By Eden
at 2018-05-13T03:24
at 2018-05-13T03:24
By Charlotte
at 2018-05-14T17:28
at 2018-05-14T17:28
By Poppy
at 2018-05-19T02:04
at 2018-05-19T02:04
By Sarah
at 2018-05-21T04:24
at 2018-05-21T04:24
By Hamiltion
at 2018-05-25T17:18
at 2018-05-25T17:18
By Eden
at 2018-05-26T02:00
at 2018-05-26T02:00
By Edward Lewis
at 2018-05-29T10:01
at 2018-05-29T10:01
By Jessica
at 2018-05-30T01:29
at 2018-05-30T01:29
By Carolina Franco
at 2018-06-02T14:00
at 2018-06-02T14:00
By Frederic
at 2018-06-03T09:33
at 2018-06-03T09:33
By Hamiltion
at 2018-06-07T10:47
at 2018-06-07T10:47
By Margaret
at 2018-06-07T23:18
at 2018-06-07T23:18
By Hamiltion
at 2018-06-10T10:00
at 2018-06-10T10:00
By Eartha
at 2018-06-14T11:03
at 2018-06-14T11:03
By Oliver
at 2018-06-16T14:37
at 2018-06-16T14:37
By Emily
at 2018-06-20T07:44
at 2018-06-20T07:44
By Skylar Davis
at 2018-06-24T03:05
at 2018-06-24T03:05
By Ingrid
at 2018-06-28T19:38
at 2018-06-28T19:38
By Cara
at 2018-07-02T14:22
at 2018-07-02T14:22
By Leila
at 2018-07-03T03:47
at 2018-07-03T03:47
By Genevieve
at 2018-07-06T13:00
at 2018-07-06T13:00
By James
at 2018-07-07T06:32
at 2018-07-07T06:32
By Rebecca
at 2018-07-09T04:31
at 2018-07-09T04:31
By Christine
at 2018-07-09T20:17
at 2018-07-09T20:17
By Dorothy
at 2018-07-13T23:11
at 2018-07-13T23:11
By Hedda
at 2018-07-17T08:25
at 2018-07-17T08:25
By Joseph
at 2018-07-19T01:57
at 2018-07-19T01:57
By Caroline
at 2018-07-20T10:19
at 2018-07-20T10:19
By Thomas
at 2018-07-20T21:08
at 2018-07-20T21:08
By Yedda
at 2018-07-21T22:25
at 2018-07-21T22:25
By Thomas
at 2018-07-25T07:53
at 2018-07-25T07:53
By Ethan
at 2018-07-29T12:22
at 2018-07-29T12:22
By Jessica
at 2018-08-01T23:33
at 2018-08-01T23:33
By Candice
at 2018-08-03T21:30
at 2018-08-03T21:30
By Frederica
at 2018-08-06T07:56
at 2018-08-06T07:56
By Kama
at 2018-08-06T12:45
at 2018-08-06T12:45
By Thomas
at 2018-08-07T01:09
at 2018-08-07T01:09
By Kristin
at 2018-08-07T11:36
at 2018-08-07T11:36
By Ursula
at 2018-08-11T02:24
at 2018-08-11T02:24
By Zora
at 2018-08-14T21:39
at 2018-08-14T21:39
By Puput
at 2018-08-18T20:47
at 2018-08-18T20:47
By Susan
at 2018-08-20T22:07
at 2018-08-20T22:07
By Elizabeth
at 2018-08-21T00:49
at 2018-08-21T00:49
By Yedda
at 2018-08-25T08:42
at 2018-08-25T08:42
By Charlotte
at 2018-08-26T05:21
at 2018-08-26T05:21
By Skylar Davis
at 2018-08-28T23:01
at 2018-08-28T23:01
By Irma
at 2018-08-31T03:57
at 2018-08-31T03:57
By Sierra Rose
at 2018-09-04T12:44
at 2018-09-04T12:44
By Victoria
at 2018-09-08T20:16
at 2018-09-08T20:16
By Belly
at 2018-09-09T09:52
at 2018-09-09T09:52
By Charlie
at 2018-09-13T19:51
at 2018-09-13T19:51
By Joe
at 2018-09-14T15:54
at 2018-09-14T15:54
By Liam
at 2018-09-19T15:24
at 2018-09-19T15:24
By Anonymous
at 2018-09-21T17:13
at 2018-09-21T17:13
By Lauren
at 2018-09-22T15:00
at 2018-09-22T15:00
By Emma
at 2018-09-25T08:04
at 2018-09-25T08:04
By Ida
at 2018-09-28T02:43
at 2018-09-28T02:43
By Kumar
at 2018-09-29T02:42
at 2018-09-29T02:42
By Adele
at 2018-10-02T14:00
at 2018-10-02T14:00
By Anonymous
at 2018-10-05T07:43
at 2018-10-05T07:43
By Anthony
at 2018-10-08T23:58
at 2018-10-08T23:58
By Charlotte
at 2018-10-10T15:57
at 2018-10-10T15:57
By David
at 2018-10-12T02:14
at 2018-10-12T02:14
By Elizabeth
at 2018-10-13T05:25
at 2018-10-13T05:25
By Noah
at 2018-10-16T05:22
at 2018-10-16T05:22
By Queena
at 2018-10-21T05:17
at 2018-10-21T05:17
By Necoo
at 2018-10-23T23:11
at 2018-10-23T23:11
By Iris
at 2018-10-28T05:20
at 2018-10-28T05:20
By Anonymous
at 2018-10-28T15:29
at 2018-10-28T15:29
By Todd Johnson
at 2018-10-29T23:35
at 2018-10-29T23:35
By Agatha
at 2018-11-01T17:31
at 2018-11-01T17:31
By Lucy
at 2018-11-06T11:36
at 2018-11-06T11:36
By Jack
at 2018-11-07T13:47
at 2018-11-07T13:47
By Quanna
at 2018-11-09T08:10
at 2018-11-09T08:10
By Agatha
at 2018-11-12T04:02
at 2018-11-12T04:02
By Ursula
at 2018-11-13T14:26
at 2018-11-13T14:26
By Agnes
at 2018-11-17T19:16
at 2018-11-17T19:16
By Quintina
at 2018-11-18T19:52
at 2018-11-18T19:52
By Ursula
at 2018-11-20T03:04
at 2018-11-20T03:04
By Frederic
at 2018-11-24T00:04
at 2018-11-24T00:04
By Charlotte
at 2018-11-27T02:25
at 2018-11-27T02:25
By Emily
at 2018-11-30T22:26
at 2018-11-30T22:26
By Iris
at 2018-12-04T14:44
at 2018-12-04T14:44
By Olivia
at 2018-12-08T06:37
at 2018-12-08T06:37
By Bennie
at 2018-12-12T13:15
at 2018-12-12T13:15
By Madame
at 2018-12-15T06:24
at 2018-12-15T06:24
By Robert
at 2018-12-19T21:49
at 2018-12-19T21:49
By Jack
at 2018-12-24T18:16
at 2018-12-24T18:16
By Sierra Rose
at 2018-12-27T03:01
at 2018-12-27T03:01
By Freda
at 2018-12-29T23:47
at 2018-12-29T23:47
By Jake
at 2019-01-01T21:54
at 2019-01-01T21:54
By Quintina
at 2019-01-05T21:04
at 2019-01-05T21:04
By Faithe
at 2019-01-07T19:10
at 2019-01-07T19:10
By Olga
at 2019-01-11T10:27
at 2019-01-11T10:27
By Kama
at 2019-01-15T09:13
at 2019-01-15T09:13
By Dinah
at 2019-01-15T22:23
at 2019-01-15T22:23
By Skylar DavisLinda
at 2019-01-18T17:45
at 2019-01-18T17:45
By Donna
at 2019-01-21T10:45
at 2019-01-21T10:45
By Thomas
at 2019-01-24T15:09
at 2019-01-24T15:09
By Susan
at 2019-01-27T03:10
at 2019-01-27T03:10
By Gary
at 2019-01-29T12:53
at 2019-01-29T12:53
By Margaret
at 2019-02-02T18:44
at 2019-02-02T18:44
By Aaliyah
at 2019-02-04T18:33
at 2019-02-04T18:33
By Rae
at 2019-02-07T08:04
at 2019-02-07T08:04
By Daniel
at 2019-02-12T05:39
at 2019-02-12T05:39
By Susan
at 2019-02-16T07:34
at 2019-02-16T07:34
By Bennie
at 2019-02-20T08:32
at 2019-02-20T08:32
By Caroline
at 2019-02-22T11:33
at 2019-02-22T11:33
By Bennie
at 2019-02-24T18:44
at 2019-02-24T18:44
By Lily
at 2019-02-25T14:55
at 2019-02-25T14:55
By Bennie
at 2019-03-01T15:04
at 2019-03-01T15:04
By Hazel
at 2019-03-03T04:04
at 2019-03-03T04:04
By Sierra Rose
at 2019-03-07T17:49
at 2019-03-07T17:49
By Ina
at 2019-03-09T08:20
at 2019-03-09T08:20
By Jake
at 2019-03-11T04:08
at 2019-03-11T04:08
By Kumar
at 2019-03-16T02:13
at 2019-03-16T02:13
By Skylar Davis
at 2019-03-20T13:46
at 2019-03-20T13:46
By Daph Bay
at 2019-03-21T23:03
at 2019-03-21T23:03
By Kama
at 2019-03-22T23:40
at 2019-03-22T23:40
By Tristan Cohan
at 2019-03-25T22:32
at 2019-03-25T22:32
By Odelette
at 2019-03-30T17:37
at 2019-03-30T17:37
By Noah
at 2019-04-02T16:54
at 2019-04-02T16:54
By Gilbert
at 2019-04-07T12:32
at 2019-04-07T12:32
By Una
at 2019-04-09T19:22
at 2019-04-09T19:22
By Gilbert
at 2019-04-14T05:37
at 2019-04-14T05:37
By Noah
at 2019-04-15T04:44
at 2019-04-15T04:44
By George
at 2019-04-15T14:07
at 2019-04-15T14:07
By Daph Bay
at 2019-04-18T23:16
at 2019-04-18T23:16
By Kumar
at 2019-04-23T16:01
at 2019-04-23T16:01
By Delia
at 2019-04-25T21:21
at 2019-04-25T21:21
By Tom
at 2019-04-29T22:12
at 2019-04-29T22:12
By Odelette
at 2019-04-30T20:43
at 2019-04-30T20:43
By Tom
at 2019-05-01T09:52
at 2019-05-01T09:52
By Joseph
at 2019-05-01T15:12
at 2019-05-01T15:12
By Daph Bay
at 2019-05-05T22:46
at 2019-05-05T22:46
By Erin
at 2019-05-07T07:57
at 2019-05-07T07:57
By Thomas
at 2019-05-08T03:14
at 2019-05-08T03:14
By Yuri
at 2019-05-11T02:03
at 2019-05-11T02:03
By Lydia
at 2019-05-12T12:15
at 2019-05-12T12:15
By Kyle
at 2019-05-16T18:37
at 2019-05-16T18:37
By Connor
at 2019-05-20T15:18
at 2019-05-20T15:18
By Brianna
at 2019-05-24T05:12
at 2019-05-24T05:12
By Charlotte
at 2019-05-26T18:48
at 2019-05-26T18:48
By Charlotte
at 2019-05-31T02:15
at 2019-05-31T02:15
By Charlotte
at 2019-06-01T09:03
at 2019-06-01T09:03
By Rosalind
at 2019-06-04T03:26
at 2019-06-04T03:26
By Elvira
at 2019-06-04T15:01
at 2019-06-04T15:01
By Edward Lewis
at 2019-06-05T22:19
at 2019-06-05T22:19
By Sierra Rose
at 2019-06-08T01:57
at 2019-06-08T01:57
By Rosalind
at 2019-06-09T12:42
at 2019-06-09T12:42
By Kama
at 2019-06-13T21:28
at 2019-06-13T21:28
By Jack
at 2019-06-18T14:49
at 2019-06-18T14:49
By Mason
at 2019-06-23T01:20
at 2019-06-23T01:20
Related Posts
華碩萬元有找便宜顯卡外接XG Station Pro
By Hazel
at 2018-01-05T10:22
at 2018-01-05T10:22
華碩多款路由器推出AiMesh混網功能
By Delia
at 2018-01-05T10:22
at 2018-01-05T10:22
華碩30天福利品 HD7970 甩賣
By Jack
at 2018-01-05T10:21
at 2018-01-05T10:21
Intel嚴重漏洞 OS更新將會降低效能
By Tracy
at 2018-01-05T09:45
at 2018-01-05T09:45
視博通 小尖兵 3.5吋硬碟架
By Adele
at 2018-01-05T09:43
at 2018-01-05T09:43