Improve FORTIFY failure diagnostics.
Our FORTIFY _chk functions' implementations were very repetitive and verbose
but not very helpful. We'd also screwed up and put the SSIZE_MAX checks where
they would never fire unless you actually had a buffer as large as half your
address space, which probably doesn't happen very often.
Factor out the duplication and take the opportunity to actually show details
like how big the overrun buffer was, or by how much it was overrun.
Also remove the obsolete FORTIFY event logging.
Also remove the unused __libc_fatal_no_abort.
This change doesn't improve the diagnostics from the optimized assembler
implementations.
Change-Id: I176a90701395404d50975b547a00bd2c654e1252
diff --git a/libc/arch-arm/denver/bionic/__strcat_chk.S b/libc/arch-arm/denver/bionic/__strcat_chk.S
index a2e9c22..2fbf5d6 100644
--- a/libc/arch-arm/denver/bionic/__strcat_chk.S
+++ b/libc/arch-arm/denver/bionic/__strcat_chk.S
@@ -27,7 +27,6 @@
*/
#include <private/bionic_asm.h>
-#include <private/libc_events.h>
.syntax unified
@@ -201,12 +200,9 @@
.cfi_rel_offset r5, 4
ldr r0, error_message
- ldr r1, error_code
1:
add r0, pc
- bl __fortify_chk_fail
-error_code:
- .word BIONIC_EVENT_STRCAT_BUFFER_OVERFLOW
+ bl __fortify_fatal
error_message:
.word error_string-(1b+4)
END(__strcat_chk_failed)
diff --git a/libc/arch-arm/denver/bionic/__strcpy_chk.S b/libc/arch-arm/denver/bionic/__strcpy_chk.S
index db76686..36188b0 100644
--- a/libc/arch-arm/denver/bionic/__strcpy_chk.S
+++ b/libc/arch-arm/denver/bionic/__strcpy_chk.S
@@ -27,7 +27,6 @@
*/
#include <private/bionic_asm.h>
-#include <private/libc_events.h>
.syntax unified
@@ -165,12 +164,9 @@
.cfi_rel_offset lr, 4
ldr r0, error_message
- ldr r1, error_code
1:
add r0, pc
- bl __fortify_chk_fail
-error_code:
- .word BIONIC_EVENT_STRCPY_BUFFER_OVERFLOW
+ bl __fortify_fatal
error_message:
.word error_string-(1b+4)
END(__strcpy_chk_failed)
diff --git a/libc/arch-arm/denver/bionic/memcpy.S b/libc/arch-arm/denver/bionic/memcpy.S
index 410b663..c1db06c 100644
--- a/libc/arch-arm/denver/bionic/memcpy.S
+++ b/libc/arch-arm/denver/bionic/memcpy.S
@@ -56,7 +56,6 @@
// Prototype: void *memcpy (void *dst, const void *src, size_t count).
#include <private/bionic_asm.h>
-#include <private/libc_events.h>
.text
.syntax unified
@@ -88,12 +87,9 @@
.cfi_rel_offset lr, 0
ldr r0, error_message
- ldr r1, error_code
1:
add r0, pc
- bl __fortify_chk_fail
-error_code:
- .word BIONIC_EVENT_MEMCPY_BUFFER_OVERFLOW
+ bl __fortify_fatal
error_message:
.word error_string-(1b+8)
END(__memcpy_chk_fail)
diff --git a/libc/arch-arm/denver/bionic/memmove.S b/libc/arch-arm/denver/bionic/memmove.S
index 132190b..94302f3 100644
--- a/libc/arch-arm/denver/bionic/memmove.S
+++ b/libc/arch-arm/denver/bionic/memmove.S
@@ -28,7 +28,6 @@
*/
#include <private/bionic_asm.h>
-#include <private/libc_events.h>
.text
.syntax unified
diff --git a/libc/arch-arm/denver/bionic/memset.S b/libc/arch-arm/denver/bionic/memset.S
index d77c244..6fac194 100644
--- a/libc/arch-arm/denver/bionic/memset.S
+++ b/libc/arch-arm/denver/bionic/memset.S
@@ -29,7 +29,6 @@
#include <machine/cpu-features.h>
#include <private/bionic_asm.h>
-#include <private/libc_events.h>
/*
* Optimized memset() for ARM.
@@ -52,12 +51,9 @@
ldr r0, error_message
- ldr r1, error_code
1:
add r0, pc
- bl __fortify_chk_fail
-error_code:
- .word BIONIC_EVENT_MEMSET_BUFFER_OVERFLOW
+ bl __fortify_fatal
error_message:
.word error_string-(1b+8)
END(__memset_chk)