<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 - __cfi_check not aligned to 4k on relocatable files with no executable code"
href="https://bugs.llvm.org/show_bug.cgi?id=46293">46293</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>__cfi_check not aligned to 4k on relocatable files with no executable code
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</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>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>peter@pcc.me.uk
</td>
</tr>
<tr>
<th>Reporter</th>
<td>samitolvanen@google.com
</td>
</tr>
<tr>
<th>CC</th>
<td>eugeni.stepanov@gmail.com, htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, ndesaulniers@google.com
</td>
</tr></table>
<p>
<div>
<pre>When building a Linux kernel module with no executable code using
-fsanitize=cfi + -fsanitize-cfi-cross-dso, I noticed the compiler-generated
__cfi_check function was not aligned to 4096 bytes as expected:
$ echo "int a;" > test.c
$ clang -flto=thin -fvisibility=default \
-fsanitize=cfi -fsanitize-cfi-cross-dso -c test.c
$ ld.lld -r -o test.ko test.o
$ llvm-readelf -S --wide test.ko
...
Section Headers:
[Nr] Name Type Address Off Size ES Flg
Lk Inf Al
[ 2] .text.__cfi_check_fail PROGBITS 0000000000000000 000040 000026 00 AX
0 0 16
...
Note Al = 16 in the section header. Adding a function to the file results in
__cfi_check to be aligned to 4096 again:
$ echo "int a; void b() {}" > test.c
$ clang -flto=thin -fvisibility=default \
-fsanitize=cfi -fsanitize-cfi-cross-dso -c test.c
$ ld.lld -r -o test.ko test.o
$ llvm-readelf -S --wide test.ko
...
Section Headers:
[Nr] Name Type Address Off Size ES Flg
Lk Inf Al
[ 2] .text.__cfi_check PROGBITS 0000000000000000 001000 000032 00 AX
0 0 4096
...
I couldn't find documentation that says __cfi_check is guaranteed to be aligned
to 4k, but it's implied in the CFI design document and compiler-rt's CFI shadow
implementation also assumes it:
<a href="https://clang.llvm.org/docs/ControlFlowIntegrityDesign.html#cfi-shadow">https://clang.llvm.org/docs/ControlFlowIntegrityDesign.html#cfi-shadow</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>