Annotate vfork for hwasan.
Call a hwasan hook in the parent return path for vfork() to let hwasan
update its shadow. See https://github.com/google/sanitizers/issues/925
for more details.
Bug: 112438058
Test: bionic-unit-tests
Change-Id: I9a06800962913e822bd66e072012d0a2c5be453d
diff --git a/libc/arch-arm64/bionic/vfork.S b/libc/arch-arm64/bionic/vfork.S
index 6acd64b..6c01572 100644
--- a/libc/arch-arm64/bionic/vfork.S
+++ b/libc/arch-arm64/bionic/vfork.S
@@ -51,5 +51,26 @@
cneg x0, x0, hi
b.hi __set_errno_internal
+#if __has_feature(hwaddress_sanitizer)
+ cbz x0, .L_exit
+
+ // Clean up stack shadow in the parent process.
+ // https://github.com/google/sanitizers/issues/925
+ stp x0, x30, [sp, #-16]!
+ .cfi_adjust_cfa_offset 16
+ .cfi_rel_offset x0, 0
+ .cfi_rel_offset x30, 8
+
+ add x0, sp, #16
+ bl __hwasan_handle_vfork
+
+ ldp x0, x30, [sp], #16
+ .cfi_adjust_cfa_offset -16
+ .cfi_restore x0
+ .cfi_restore x30
+
+#endif
+
+.L_exit:
ret
END(vfork)