]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
asan: Don't instrument .ABNORMAL_DISPATCHER [PR114743]
authorJakub Jelinek <jakub@redhat.com>
Wed, 17 Apr 2024 08:24:18 +0000 (10:24 +0200)
committerJakub Jelinek <jakub@redhat.com>
Wed, 17 Apr 2024 08:24:18 +0000 (10:24 +0200)
.ABNORMAL_DISPATCHER is currently the only internal function with
ECF_NORETURN, and asan likes to instrument ECF_NORETURN calls by adding
some builtin call before them, which breaks the .ABNORMAL_DISPATCHER
discovery added in gsi_safe_*.

The following patch fixes asan not to instrument .ABNORMAL_DISPATCHER
calls, like it doesn't instrument a couple of specific builtin calls
as well.

2024-04-17  Jakub Jelinek  <jakub@redhat.com>

PR sanitizer/114743
* asan.cc (maybe_instrument_call): Don't instrument calls to
.ABNORMAL_DISPATCHER.

* gcc.dg/asan/pr112709-2.c (freddy): New function from
gcc.dg/ubsan/pr112709-2.c version of the test.

gcc/asan.cc
gcc/testsuite/gcc.dg/asan/pr112709-2.c

index 57c3a9b00e19744290d1465bbdf1bfa0d20c3b89..9e0f51b1477c8d21d32072a16c075352c18c24b8 100644 (file)
@@ -3030,6 +3030,9 @@ maybe_instrument_call (gimple_stmt_iterator *iter)
              break;
            }
        }
+      if (gimple_call_internal_p (stmt, IFN_ABNORMAL_DISPATCHER))
+       /* Don't instrument this.  */
+       return false;
       /* If a function does not return, then we must handle clearing up the
         shadow stack accordingly.  For ASAN we can simply set the entire stack
         to "valid" for accesses by setting the shadow space to 0 and all
index e793f53507f806289e762fb2bc8e07c2d91181ef..6fa3491c7eb4720dee5b62dbb1221edbcb0a0ac3 100644 (file)
@@ -48,3 +48,15 @@ l3:
   if (x < 4)
     goto *q[x & 3];
 }
+
+void
+freddy (int x, int *y, struct S *p)
+{
+  bar (*p);
+  ++p;
+  if (x == 25)
+    x = foo (2);
+  else if (x == 42)
+    x = foo (foo (3));
+  *y = bar (*p);
+}