ubsan: Use right address space for MEM_REF created for bool/enum sanitization [PR115172]
commitd224c7d8d8b49daab54a977a4f2217423d3d12a0
authorJakub Jelinek <jakub@redhat.com>
Wed, 22 May 2024 07:12:28 +0000 (22 09:12 +0200)
committerJakub Jelinek <jakub@redhat.com>
Wed, 22 May 2024 07:19:00 +0000 (22 09:19 +0200)
tree5a6f46ba7136b0ba4907099c004bfba27747f5f9
parent1ad5c9d524d8fa99773045e75da04ae958012085
ubsan: Use right address space for MEM_REF created for bool/enum sanitization [PR115172]

The following testcase is miscompiled, because -fsanitize=bool,enum
creates a MEM_REF without propagating there address space qualifiers,
so what should be normally loaded using say %gs:/%fs: segment prefix
isn't.  Together with asan it then causes that load to be sanitized.

2024-05-22  Jakub Jelinek  <jakub@redhat.com>

PR sanitizer/115172
* ubsan.cc (instrument_bool_enum_load): If rhs is not in generic
address space, use qualified version of utype with the right
address space.  Formatting fix.

* gcc.dg/asan/pr115172.c: New test.

(cherry picked from commit d3c506eff54fcbac389a529c2e98da108a410b7f)
gcc/testsuite/gcc.dg/asan/pr115172.c [new file with mode: 0644]
gcc/ubsan.cc