<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/54192>54192</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Stack buffer overflows don't throw exception when stack tagging enabled with arm64 MTE
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
aditi741997
</td>
</tr>
</table>
<pre>
I am compiling the following code [test_mte_stack2_code.txt](https://github.com/llvm/llvm-project/files/8183382/test_mte_stack2_code.txt)] using 'clang-11 -target aarch64-linux-gnu -march=armv8.5-a+memtag -fsanitize=memtag -I/usr/aarch64-linux-gnu/include/c++/9/aarch64-linux-gnu test_mte_stack2.cpp -static'.
I run the executable on a VM in QEMU, with MTE on [I ran the example code in ? and got a segfault, meaning QEMU, Kernel are behaving correctly]
I observed that
1. local variables in main() are not getting tagged
2. In test function, local variables are being tagged but I am able to do stack buffer overflow from arr2 into arr1, without modifying the tag.
3. Similarly in test2, which gets the pointer to one of test's local variables (a), i can read (i.e. overflow into) test's other local variables using the pointer to a.
What are the reasons behind the above? Shouldn't the tag be checked for accesses in functions test, test2 to detect overflow?
I have attached the assembly file [test_mte_stack2_assembly.txt](https://github.com/llvm/llvm-project/files/8183416/test_mte_stack2_assembly.txt)
[which has no ldg instructions] and the output of running the executable in the VM
[test_mte_stack2_output.txt](https://github.com/llvm/llvm-project/files/8183419/test_mte_stack2_output.txt).
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJytVctu2zoQ_Rp5M7BgPfxaaNE2DRAUWRS5j2VASUOJtxRpkJSb3K-_h5LVNIm7uEABw6Yo8syZc2bGtW2fqzsSAzV2OCmtTEehZ5JWa_s9PjW2ZUq2HwP78DgEfvRBNN_yx7ifhqeQbG-S_NCHcPJJ8SHJb_HpVOjHOgUkHrQ-Lz_rk7P_cBPwKJVmj99DdiiKQ47VLwPkR8Sg0Uc2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