<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - speculative load hardening is insecure"
href="https://bugs.llvm.org/show_bug.cgi?id=46202">46202</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>speculative load hardening is insecure
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</td>
</tr>
<tr>
<th>Version</th>
<td>10.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>mp@cs.stanford.edu
</td>
</tr>
<tr>
<th>CC</th>
<td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=23577" name="attach_23577" title="c and asm files">attachment 23577</a> <a href="attachment.cgi?id=23577&action=edit" title="c and asm files">[details]</a></span>
c and asm files
The way SLH is applied in order to mask values that are loaded from memory is
insecure.
Take the code in the c attachment.
a high-level summary of that code is :
void get (int y) x = A[y];
if (y < size)
temp = B[x];
Compiling it with Clang 10 with -x86-speculative-load-hardening flag enabled
emits the code in the asm attachment, whose simplification is :
mov rax, rsp // load predicate bit from stack pointer
sar rax, 63 // initialize mask (0xF...F if left−most bit of rax is 1) movzx
edx, [A + rdi] // load A[y]
or edx, eax // mask A[y]
mov x, edx // assignment to x
mov esi, size // load size
cmp rsi, rdi // compare size and y
jbe ELSE // jump if out−of−bound
THEN:
cmovbe rax, −1 // set mask to −1 if out−of−bound mov cl, [B + rdx] // load B[x]
or cl, al // mask B[x]
mov temp, cl // assignment to temp
jmp END
ELSE:
cmova rax, −1 // set mask to −1 if in−bound
END:
shl rax, 47
or rsp, rax // store predicate bit on stack pointer ret
the masking of A[y] is ineffective, so when its content is accessed during
speculation, it is not masked.
This leads to speculative leaks, i.e., the SLH countermeasure is ineffective.
A longer detail of this bug can be found here, see Section V (please access it
after Friday June 5th, new version is being uploaded)
<a href="https://arxiv.org/pdf/1910.08607.pdf">https://arxiv.org/pdf/1910.08607.pdf</a>
In short, SLH currently masks the output of memory instructions.
The fix is to mask the input of memory operations and not the output.
Concretely, a good fix is discussed in a longer technical work of Blade:
<a href="https://arxiv.org/pdf/2005.00294.pdf">https://arxiv.org/pdf/2005.00294.pdf</a></pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>