<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/89670>89670</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Sanitizer handler calls emitted without regard to `-mregparm`
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
kees
</td>
</tr>
</table>
<pre>
When sanitizer calls are emitted, the `-mregparm=3` option used by the Linux kernel appears to be ignored. For example, here is a build where the argument are being pushed instead of placed in `%eax` and `%edx` (from `lkdtm_ARRAY_BOUNDS`):
```asm
0xc18e3a5a <+202>: push %ebx
0xc18e3a5b <+203>: push $0xc26001a0
0xc18e3a60 <+208>: call 0xc157d430 <__ubsan_handle_out_of_bounds>
```
The kernel's handler isn't expecting them on the stack. For example, this is setting a bit in the sanitizer's passed-in data structure (from `__ubsan_handle_out_of_bounds`):
```asm
0xc157d491 <+97>: btsl $0x1f,%ds:0x4(%eax)
0xc157d497 <+103>: jae 0xc157d4a1 <__ubsan_handle_out_of_bounds+113>
```
https://github.com/KSPP/linux/issues/350
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVF1vrDYQ_TXel1FWZgwLPPCwSbovrdqrm1ZVn1YGz4JvjEG2abj99ZUdkmwUNb3SapGGOfNxznCk97q3RA0rbllxv5NLGCbXPBL5XTup782fA1nw0uqg_yEHnTTGg3QENOoQSDG8gzAQsAO_GR31s3QjE_eCHThMc9CThcWTgvZ7SvtF22WFR3KWDMh5Juk8hAlaAt3byZHaw2lyQKscZ0Ox-kCOQHuQ0C7aKHhKgVhMun4ZyYY0T0va9jAvfiAF2vpAUsF0gdnILkXiiAwLkmucTVr1ElApwLC6uGmMQfOowng-fv16_Ot8-9sfv94_pMyaiSPj94y__B_480_68TkCfO2yioQsJDBxx_AWOTLxExNHgDQbAMSW7boB4A3SvkLEewjDnK8dHjjPJP-Ai6NvuOoVF2XacopS5SLlnM9L66U9D9IqQ-dpCefpcm6nxSofke-Xut7094E2zRiWHp4LONDeMiwD0DpTFyL9YaARJpvU8UF2jx_UDIP2UU1PISEktDpEdRLk5c5Sm1l6T-pGW1AySPDBLV1YHF1L9elOPyjaG091tnFZlxuVbfAmaZbzNbswvGNYRLaOfM0ZVts9Yf2xVLmVyq7k_CYJrnJk9r-y4G2WiTdx_luiIYQ5zsXwxPDU6zAs7b6bRoannx--fGF4MvHTY3jS3i_kGZ5EwXeqEaoWtdxRk5WZqDATdbUbGqorKkSdK4GirEV3QYGKF0WR4eVQFLTTDXLMeY6IGdZFtS8vFeeyKEWmygzLkuWcRqnN3pi_x_3k-l1q3FT1oeQ7I1syPrkOoqUnSC8ZYjQh10TMTbv0nuXcaB_8W5Wgg6Hm4dWRXo7x2Zk2V4InHYZpCeCol05Fh3lnUAe-W5xpPiEt9tseN7ObvlEXrrlLW_wbAAD__8-ck4s">