<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 - clang BPF wrong code generation, if branch"
href="https://bugs.llvm.org/show_bug.cgi?id=43843">43843</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>clang BPF wrong code generation, if branch
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>9.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>Other
</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>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>eugene.loh@oracle.com
</td>
</tr>
<tr>
<th>CC</th>
<td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=22746" name="attach_22746" title="sample C code + script to see assembly + script to try with BPF verifier">attachment 22746</a> <a href="attachment.cgi?id=22746&action=edit" title="sample C code + script to see assembly + script to try with BPF verifier">[details]</a></span>
sample C code + script to see assembly + script to try with BPF verifier
A sample C code seems to lead to incorrect code generation. The code is
basically
int foo() {
unsigned long long ptr1, ptr2, in[2];
char out[256];
ptr1 = ((unsigned long long) out) + 16;
if (ptr1)
bpf_probe_read((void *) ptr1, 16, (const void *) in);
ptr2 = ((unsigned long long) out) + 32;
if (ptr2)
bpf_probe_read((void *) ptr2, 16, (const void *) in);
return 0;
}
The "if (ptr)" branches should always be taken. These code paths seem to be
generated correctly.
If either "ptr*" is 0, however, the generated code is bad. That shouldn't
matter, but for BPF the BPF verifier analyzes those paths and ends up rejecting
legitimate code.
I'm attaching an example.</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>