<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 - Shrink wrap can leave accesses to stack objects after frame destruction"
href="https://bugs.llvm.org/show_bug.cgi?id=42136">42136</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Shrink wrap can leave accesses to stack objects after frame destruction
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</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>Common Code Generator Code
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>david.green@arm.com
</td>
</tr>
<tr>
<th>CC</th>
<td>efriedma@quicinc.com, llvm-bugs@lists.llvm.org, t.p.northover@gmail.com
</td>
</tr></table>
<p>
<div>
<pre>Something like this code:
void compiler_pop_stack(unsigned num)
{
unsigned rstack[16];
if (num <= 1U) {
return;
}
rstack[0] = 0;
for (unsigned ptr = 1; ptr > 0; ptr--) {
if (0 < rstack[ptr]) {
ptr++;
}
}
}
Produces this assembly:
clang --target=aarch64-arm-none-eabi -march=armv8-a -Os test.c -S -o -
.globl compiler_pop_stack
.p2align 2
.type compiler_pop_stack,@function
compiler_pop_stack:
cmp w0, #2
b.lo .LBB0_3
str wzr, [sp, #-64]! <<< Stack is setup
mov w8, #1
mov x9, sp
add sp, sp, #64 <<< Stack is restored
.LBB0_2:
ldr w10, [x9, w8, uxtw #2] <<< Stack object is used in loop
cmp w10, #0
cinc w8, w8, ne
subs w8, w8, #1
b.ne .LBB0_2
.LBB0_3:
ret
If we take an exception between the stack restore and the accesses in the loop,
we can end up corrupting the stack items that are still in use.</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>