]> gcc.gnu.org Git - gcc.git/commit
ubsan: Don't -fsanitize=null instrument __seg_fs/gs pointers [PR111736]
authorJakub Jelinek <jakub@redhat.com>
Fri, 22 Mar 2024 08:23:44 +0000 (09:23 +0100)
committerUros Bizjak <ubizjak@gmail.com>
Wed, 24 Apr 2024 14:39:21 +0000 (16:39 +0200)
commit624c3bb9ff762f196852dc77233610d1cdf7d7be
treefe2c4fa6ac8be5e9aad5554514c0629c076c694f
parentb4e1aee01a2fa617cf74ab04cf0ab574761aaaea
ubsan: Don't -fsanitize=null instrument __seg_fs/gs pointers [PR111736]

On x86 and avr some address spaces allow 0 pointers (on avr actually
even generic as, but libsanitizer isn't ported to it and
I'm not convinced we should completely kill -fsanitize=null in that
case).
The following patch makes sure those aren't diagnosed for -fsanitize=null,
though they are still sanitized for -fsanitize=alignment.

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

gcc/ChangeLog:

PR sanitizer/111736
* ubsan.c (ubsan_expand_null_ifn, instrument_mem_ref): Avoid
SANITIZE_NULL instrumentation for non-generic address spaces
for which targetm.addr_space.zero_address_valid (as) is true.

gcc/testsuite/ChangeLog:

* gcc.dg/ubsan/pr111736.c: New test.

(cherry picked from commit ddd4a3ca87410886b039cc225907b4f6e650082e)
gcc/testsuite/gcc.dg/ubsan/pr111736.c [new file with mode: 0644]
gcc/ubsan.c
This page took 0.073429 seconds and 5 git commands to generate.